Logger for the logging module that writes messages to the database
Project description
django-logging-eventlog
Logger for the logging module that writes messages to the django database
Installation
Install using pip:
pip install --upgrade django-logging-eventlog
Modify your settings.py. Add eventlog to your INSTALLED_APPS:
INSTALLED_APPS = [ #django apps 'eventlog', #your apps ]
Configure LOGGING in your settings.py for example:
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'eventlog': { 'class': 'eventlog.services.EventLogHandler' }, 'console': { 'class': 'logging.StreamHandler', }, }, 'loggers': { 'root': { 'handlers': ['console', 'eventlog'], 'level': 'INFO', 'propagate': True, }, } }
Run python manage.py makemigrations eventlog and run Run python manage.py migrate
Usage
import logging
logger = logging.getLogger(__name__)
logger.info('info')
logger.debug('debug')
logger.error('error')
logger.critical('critical')
logger.warning('warning')
try:
1/0
except Exception as ex:
logger.exception(ex, exc_info=ex)
To prune the eventlog, use the command as pruneeventlog. For example, to keep records in the database only for the last 30 days, run:
python manage.py pruneeventlog 30
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-logging-eventlog-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 685d47f63c24c6d3719e966287399891a03e6d99eefcea0de8d856f3a6c9b239 |
|
MD5 | 19762a28389635967c8ef14d26e149bc |
|
BLAKE2b-256 | d79e26068721ac334105f7dc0acbedb3dd97df556773332d7b78e85449849391 |
Close
Hashes for django_logging_eventlog-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7ab0ddb65cc2d70e4784a5c9d86fc7cfa97e231bd32709599c848b5cbe943e8 |
|
MD5 | e52812c59624ca7eae530039d72a0d1c |
|
BLAKE2b-256 | 201559282e07f4bfe3772e0c8ba42507648e355f1d3f58ab2d94ac0da98e50c7 |