I am using Django and have included Python's default logging library. I have following configuration for logging (in settings.py):
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format' : "[%(asctime)s %(name)s-%(levelname)s (%(filename)s:%(lineno)s %(funcName)s)]: %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '[%(asctime)s %(name)s-%(levelname)s]: %(message)s',
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
},
'handlers': {
'file-django': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(PROJECT_LOGS, 'django.log'),
'formatter': 'simple'
},
'file-application': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(PROJECT_LOGS, 'application.log'),
'formatter': 'simple'
},
'file-core': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(PROJECT_LOGS, 'core.log'),
'formatter': 'verbose'
},
},
'loggers': {
'django': {
'handlers':['file-django'],
'propagate': True,
'level':'DEBUG',
},
'application': {
'handlers': ['file-application'],
'propagate': True,
'level': 'DEBUG',
},
'core': {
'handlers': ['file-core'],
'propagate': True,
'level': 'DEBUG',
},
}
}
I am trying to split result logging files using only configuration. I "googled" and found few solutions but all of them are code based.
RotatingFileHandler?