Django Rotating Log
Add a Rotating Log to your Django Project#
Use the RotatingFileHandler a log handler that comes with Python
In your django settings file:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'debug.log'),
'maxBytes': 1024 * 1024 * 15, # 15MB
'backupCount': 10,
},
},
'loggers': {
'django': {
'handlers': ['file', ],
'level': 'INFO',
'propagate': True,
},
},
}