Enable logging by setting by setting ENABLE_DEBUG_LOG
in .env
Also set the modules to log by using `MODULES_TO_LOG` config parameter in .env
This commit is contained in:
parent
bbb6f3290d
commit
38c7283cb6
1 changed files with 31 additions and 0 deletions
|
@ -206,3 +206,34 @@ LOGGING = {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
if config('ENABLE_DEBUG_LOG', False):
|
||||
loggers_dict = {}
|
||||
LOGGING['handlers']['file'] = {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_DIR, 'debug.log'),
|
||||
}
|
||||
|
||||
MODULES_TO_LOG = config('MODULES_TO_LOG', 'django')
|
||||
LOGGING['handlers']['file'] = {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_DIR, 'debug.log'),
|
||||
}
|
||||
|
||||
if MODULES_TO_LOG is None:
|
||||
# set MODULES_TO_LOG to django, if it is not set
|
||||
MODULES_TO_LOG = 'django'
|
||||
modules_to_log_list = MODULES_TO_LOG.split(',')
|
||||
for custom_module in modules_to_log_list:
|
||||
logger_item = {
|
||||
custom_module: {
|
||||
'handlers': ['file'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True
|
||||
}
|
||||
}
|
||||
loggers_dict.update(logger_item)
|
||||
|
||||
LOGGING['loggers'] = loggers_dict
|
||||
|
|
Loading…
Reference in a new issue