Skip to main content

A logging handler for Django that defers evaluation of the filepath

Project description

This package provides a new logging handler that defers evaluation of the filepath until a message is emitted. It uses a setting LOG_ROOT as the folder for the log files. This is useful when you don’t know the exact location of your log files when the LOGGING setting is defined - this can be the case if you have a environment specific settings file which gets imported after your core settings.

Usage

In your main settings file, configure your handlers with a filename

LOGGING = {
    ...
    'handlers': {
        'error_file': {
            'level': 'INFO',
            'class': 'deferred_filelogger.DeferredFilehandler',
            'filename': 'errors.log',
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['error_file', 'mail_admins'],
            'level': 'ERROR',
            'propagate': False
        }
    }
}

then in your environmental overrides (eg settings_local.py), specify a LOG_ROOT folder. For instance, in your test environment you might specify

LOG_ROOT = '/var/www/client/project/logs/test'

which would cause your Django errors to be logged to /var/www/client/project/logs/test/errors.log.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-deferred-filelogger-0.1.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file django-deferred-filelogger-0.1.tar.gz.

File metadata

File hashes

Hashes for django-deferred-filelogger-0.1.tar.gz
Algorithm Hash digest
SHA256 b198e885cf2ab4e0364dd0ac499bbaa8ae2fb6bbd226bdd1256e3a50300da56b
MD5 f5e3eb532dcc9a0d7d8d4882566d2c6e
BLAKE2b-256 326d00107d06ff29d5648636932045e415dbf32b132bad2c80b68aa6fec493ca

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