a = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
},
'handlers': {
'default': {
'formatter': 'standard',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout', # Default is stderr
},
'error': {
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'standard',
'filename': 'error.log',
'maxBytes': 1024,
'backupCount': '10',
'encoding': 'utf8',
}
},
'loggers': {
'': { # root logger
'handlers': ['default', 'error'],
'level': 'ERROR',
'propagate': True
},
'my.packg': {
'handlers': ['default'],
'level': 'WARN',
'propagate': False
},
}
}
python logging configure with config.py
最新推荐文章于 2024-07-01 14:33:07 发布