zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    生成排列与生成子集
    赛后总结AtCoder Beginner Contest 090(Beginner)
    树状数组笔记
    论怎么记住tarjan的板子
    tarjan缩点-受欢迎的牛-笔记
    tarjan模板(%%%hzwer)-2.0
    tarjan模板(%%%hzwer)
    匈牙利算法学习笔记
    最短路-Car的旅行路线
    数据结构 笔记1 搜索树
  • 原文地址:https://www.cnblogs.com/bill2014/p/15789210.html
Copyright © 2011-2022 走看看