Skip to main content

Logger for the logging module that writes messages to the database

Project description

License Python version Django version

django-logging-eventlog

Logger for the logging module that writes messages to the django database

http://www.mnemchinov.ru/images/projects/django-logging-eventlog/eventlog_events.jpg http://www.mnemchinov.ru/images/projects/django-logging-eventlog/eventlog_event_exception.jpg

Installation

  1. Install using pip:

    pip install --upgrade django-logging-eventlog
  2. Modify your settings.py. Add eventlog to your INSTALLED_APPS:

    INSTALLED_APPS = [
        #django apps
        'eventlog',
        #your apps
    ]
  3. 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,
            },
        }
    }
  4. 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

django-logging-eventlog-0.0.4.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

django_logging_eventlog-0.0.4-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page