[Answer]-In Django: Can I set logging level highest than CRITICAL?

1👍

You should configure a custom logger and send messages to it. For example, assuming your package is called foo:

LOGGING = {
    ...
    'handlers': {
        ...
        'file_report': {
            'level': 'INFO',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'filename': os.path.join(SITE_ROOT, '..', 'logs', 'REPORT.log'),
            'when':'midnight',
            'interval': 1,
            'backupCount': 4,
            'formatter':'simple',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['console'],
            'propagate': False,
            'level': 'DEBUG',
        },
        'foo.report': {
            'handlers': ['file_report'],
            'propagate': False,
            'level': 'INFO',
        },
    },
}

Then in your application code:

import logging
logging.getLogger('foo.report').info('something something')

Leave a comment