Skip to main content

Django logging in database

Project description

Django logging in database. For large projects please use Sentry



  • Django>=1.9
  • Python 2.7+/3.6+



Quick start

  1. Install
pip install django-db-logger
  1. Add “django_db_logger” to your INSTALLED_APPS setting like this
  1. Add handler and logger to LOGGING setting like this
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        'simple': {
            'format': '%(levelname)s %(asctime)s %(message)s'
    'handlers': {
        'db_log': {
            'level': 'DEBUG',
            'class': 'django_db_logger.db_log_handler.DatabaseLogHandler'
    'loggers': {
        'db': {
            'handlers': ['db_log'],
            'level': 'DEBUG'
  1. Run python migrate to create django-db-logger models.
  2. Use django-db-logger like this
import logging
db_logger = logging.getLogger('db')'info message')
db_logger.warning('warning message')

except Exception as e:


  1. DJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE: integer. list per page in admin view. default 10
  2. DJANGO_DB_LOGGER_ENABLE_FORMATTER: boolean. Using formatter options to format message. True or False, default False

Build your own database logger :hammer:

  1. Create a new app and add it to INSTALLED_APPS
  2. Copy files django-db-logger/, django-db-logger/, django-db-logger/ to the app folder
  3. Replace DJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE in with an integer
  4. Replace DJANGO_DB_LOGGER_ENABLE_FORMATTER in with True or False. Remove MSG_STYLE_SIMPLE, it was not used.
  5. Replace logger class django_db_logger.db_log_handler.DatabaseLogHandler in your Settings with the new logger class
  6. Customize the looger to meet your needs. :beer:

Project details

Download files

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

Files for django-db-logger, version 0.1.11
Filename, size File type Python version Upload date Hashes
Filename, size django_db_logger-0.1.11-py3-none-any.whl (8.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-db-logger-0.1.11.tar.gz (7.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page