logging
作者:互联网
参考文档,看网上的愣是没看懂
https://docs.djangoproject.com/zh-hans/3.1/topics/logging/#id3 https://github.com/jumpserver/jumpserver/blob/88ea7ae149b9d9a17a0e9324ab63f2cd992ba6c6/apps/jumpserver/settings/logging.py
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'main': { 'datefmt': '%Y-%m-%d %H:%M:%S', 'format': '%(asctime)s [%(module)s %(levelname)s] %(message)s', }, 'exception': { 'datefmt': '%Y-%m-%d %H:%M:%S', 'format': '\n%(asctime)s [%(levelname)s] %(message)s', }, 'simple': { 'format': '%(levelname)s %(message)s' }, 'syslog': { 'format': 'ops: %(message)s' }, 'msg': { 'format': '%(message)s' } }, 'filters': { 'require_debug_true': { '()': 'django.utils.log.RequireDebugTrue' } }, 'handlers': { 'null': { 'level': 'DEBUG', 'class': 'logging.NullHandler', }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'main' }, 'file': { 'encoding': 'utf8', 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'maxBytes': 1024*1024*100, 'backupCount': 7, 'formatter': 'main', 'filename': os.path.join(log_path, 'ops.log'), }, 'request': { 'encoding': 'utf8', 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'maxBytes': 1024*1024*100, 'backupCount': 7, 'formatter': 'main', 'filename': os.path.join(log_path, 'request.log'), }, 'server': { 'encoding': 'utf8', 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'maxBytes': 1024*1024*100, 'backupCount': 7, 'formatter': 'main', 'filename': os.path.join(log_path, 'server.log'), }, 'unexpected_exception': { 'encoding': 'utf8', 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'formatter': 'exception', 'maxBytes': 1024 * 1024 * 100, 'backupCount': 7, 'filename': os.path.join(log_path, 'unexpected_exception.log'), }, 'syslog': { 'level': 'INFO', 'class': 'logging.NullHandler', 'formatter': 'syslog' }, }, 'loggers': { 'django': { 'handlers': ['null'], 'propagate': False, 'level': 'INFO', }, 'django.request': { 'handlers': ['request'], 'level': 'INFO', 'propagate': False, }, 'django.server': { 'handlers': ['server'], 'level': 'INFO', 'propagate': False, }, 'ops': { 'handlers': ['file'], 'level': 'INFO', 'propagate': False, }, 'unexpected_exception': { 'handlers': ['unexpected_exception'], 'level': 'DEBUG', 'propagate': False, }, 'syslog': { 'handlers': ['syslog'], 'level': 'INFO', 'propagate': False, }, }, 'root': { # 所有propagate 为true的日志都会向上传播到root,自己记录完后会在root继续记录 'handlers': ['file'], 'level': 'INFO', 'propagate': False, }, }View Code
标签:False,log,handlers,level,logging,path 来源: https://www.cnblogs.com/bill2014/p/15789210.html