I am trying to implement TimedRotatingFileHandler with dictConfig
Here is the code:
LOG_SETTINGS = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'default': {
            'format': '%(asctime)s: %(name)s: #%(lineno)d: %(levelname)s - %(message)s'
        }
    },
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'formatter': 'default',
            'filename': logfile_name,
            'when': 'midnight',
            'interval': 1,
            'backupCount': 5
        }
    },
    'loggers': {
        ' ': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True
        },
    }
}
logfile_name =
$HOME/.local/share/app/file.logLoading dictionary with
logging.config.dictConfig(LOG_SETTINGS)Writing to file:
logging.debug("Some text")
This creates a file named file.log, but the file is completely empty. I got no errors/warnings.
I visited Basic logging dictConfig in Python. File seems quite similar.
Where did I go wrong? Using Python 3.6
 
                        
Try that:
UPDATE: In my company we use that always:
with define logger: