Skip to main content

Simple logging. Stored in database, accessed in Django admin.

Project description

Simple logging to the database for django projects. Log entries are viewed in admin.

Note: Be sparing with the number of messages logged to the database. It is convenient when you want events logged that can be viewed in the django admin, but logging excessively to the database can cripple performance.

Requirements

Django 1.7 or greater.

Install

Install package:

pip install django-lumberjack

Add 'lumberjack' to your INSTALLED_APPS:

# settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    ...
    'lumberjack',
)

Add handler and logger configs:

# settings.py

LOGGING = {
    ...
    'handlers': {
        'lumberjack_handler': {
            'level': 'DEBUG',
            'class': 'lumberjack.handlers.DBHandler',
        },
    },
    'loggers': {
        'lumberjack': {
            'handlers': ['lumberjack_handler'],
        },
    }
}

Create database tables:

$ ./manage.py migrate lumberjack

Usage

Example of logging in a view function:

# views.py

import logging

logger = logging.getLogger('lumberjack')

def someview(request):

    logger.debug('someview was called', [__name__, 'sometag'])

    ...

    try:
        # some action
        ...

    except:
        logger.error('some action failed', [__name__, 'fml'])

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-lumberjack-0.2.3.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file django-lumberjack-0.2.3.tar.gz.

File metadata

File hashes

Hashes for django-lumberjack-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5562f73a8f61f02c16dc3692ffd54a9e15a93e2c33a66e589fd60c4d2d35e22f
MD5 1ba8211ba704ebaccea80325162263f1
BLAKE2b-256 b11eb149b3faa2d7b6791c118d095d25c75fa5da30f1032ac8a1c483827bdddc

See more details on using hashes here.

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