Logging

Everything is logged in the rules_light logger:

  • rule registered is logged with DEBUG level,
  • rule run() is logged with INFO level,
  • require() failure is logged with WARN level.

Install

Example settings.LOGGING that will display all logged events in the console, as well as denials in malicious.log.

See http://docs.djangoproject.com/en/dev/topics/logging for more details on how to customize your logging configuration.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
        },
        'malicious': {
            'level': 'WARN',
            'class': 'logging.FileHandler',
            'filename': 'malicious.log',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        'rules_light': {
            'handlers': ['console', 'malicious'],
            'propagate': True,
            'level': 'DEBUG',
        },
    }
}