0
当我使用logging.config.dictConfig
设置我的日志时,如何翻转我的日志?我无法检索我的logging.handlers.RotatingFileHandler
。访问处理程序对象到翻转日志
import logging
import logging.config
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'default': {
'class':'logging.handlers.RotatingFileHandler',
"level": "DEBUG",
"filename": "test.log",
'backupCount': 5,
'maxBytes': 20,
},
},
'loggers': {
'': {
'handlers': ['default'],
'level': 'DEBUG',
'propagate': True
}
}
})
# How do I do rollover??
logging.handler[0].doRollover()
logging.info("foo")