1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| import logging.config
LOGGING_CONFIG = { 'version': 1.0, 'disable_existing_loggers': True, 'formatters': { 'verbose': { 'format': '[%(levelname)s][%(asctime)s][%(name)s][pid=%(process)d][tid=%(thread)d] %(message)s' }, 'standard': { 'format': '[%(asctime)s][%(levelname)s] %(message)s' }, }, 'handlers': { 'console': { 'level': 'INFO', 'class': 'logging.StreamHandler', 'formatter': 'verbose' }, 'time_rotate_file': { 'level': 'DEBUG', 'class': 'logging.handlers.TimedRotatingFileHandler', 'filename': LOG_FILE, 'when': 'D', 'backupCount': 30, 'encoding': 'utf8', 'formatter': 'verbose', }, 'cos_down_file': { 'level': 'DEBUG', 'class': 'logging.handlers.TimedRotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'cos_download.log'), 'when': 'D', 'backupCount': 30, 'encoding': 'utf8', 'formatter': 'verbose', }, }, 'loggers': { 'console_logger': { 'handlers': ['console', 'time_rotate_file'], 'level': 'DEBUG', 'propagate': False, }, 'qcloud_cos.cos_client': { 'handlers': ['cos_down_file'], 'level': 'DEBUG', 'propagate': False, } },
}
logging.config.dictConfig(LOGGING_CONFIG)
|