python logging configure with config.py

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
        },
    }
}
posted @ 2019-06-03 00:31  idlewith  阅读(164)  评论(0编辑  收藏  举报