The code itself doesn't seem to be a problem, but for some reason I get an error.
.
..
...
LOG_CONFIG = {
'version': 1,
...
..
.
'handlers': {
'console': {
'formatter': 'default',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stderr',
},
'output': {
'level': 'DEBUG',
'class': 'logging.handlers.TimedRotatingFileHandler',
'formatter': 'default',
'filename': '/path/to/application.log',
'when': 'MIDNIGHT',
'interval': 1,
'backupCount': 5,
},
},
...
..
.
}
...
..
.
.
..
...
File "./main.py", line 7, in <module>
load_log_config()
File "./configs/log_config.py", line 41, in load_log_config
dictConfig(LOG_CONFIG)
File "/root/local/python-3.8.5/lib/python3.8/logging/config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "/root/local/python-3.8.5/lib/python3.8/logging/config.py", line 570, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'file_output_handler'
The cause is that the directory specified in filename
does not exist (or is incorrect).
The error message was hard to understand and I was a little addicted to it ...
.
..
...
LOG_CONFIG = {
'version': 1,
...
..
.
'handlers': {
'console': {
'formatter': 'default',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stderr',
},
'output': {
'level': 'DEBUG',
'class': 'logging.handlers.TimedRotatingFileHandler',
'formatter': 'default',
'filename': '/path/to/application.log',← This
'when': 'MIDNIGHT',
'interval': 1,
'backupCount': 5,
},
},
...
..
.
}
...
..
.