Django App记录INFO级别的日志记录到HTTPD日志文件,错误

时间:2018-12-16 11:10:24

标签: django apache http logging

我正在运行几个Django应用,这是我的配置。问题是从名为 one.app 的应用程序,所有INFO级别的日志都被记录为HTTPD日志文件中的ERROR。

是否应该为one.app配置添加propogate = False?还是与Httpd配置有关?

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
    'file_log_formatter': {
        'format': '%(levelname)3.3s %(asctime)22.22s [%(module)s:%(name)s::%(funcName)s] {%(process)d} %(message)s'
    },
    'verbose': {
        'format': '%(name)-15s : %(asctime)s %(levelname)-8s %(pypath)s:%(funcName)s:%(lineno)d [%(process)d:%(thread)d] %(message)s'
    },
    'simple': {
        'format': '%(levelname)s %(message)s'
    },
    'django.server': DEFAULT_LOGGING['formatters']['django.server'],
},
'filters': {
    'require_debug_true': {
        '()': 'django.utils.log.RequireDebugTrue',
    },
},
'handlers': {
    'app_file': {
        'level': 'INFO',
        'class': 'logging.handlers.RotatingFileHandler',
        'filename': APP_LOG,
        'formatter': 'verbose',
        'backupCount': 1,  # keep at most 1 backup log file
        'maxBytes': 1024 * 1024 * 100,  # 100MB
    },
    'monitor_file': {
        'level': 'INFO',
        'class': 'logging.handlers.RotatingFileHandler',
        'filename': MONITOR_LOG,
        'formatter': 'verbose',
        'backupCount': 1,  # keep at most 1 backup log file
        'maxBytes': 1024 * 1024 * 100,  # 100MB
    },
    "celery_console": {
        "level": "DEBUG",
        "class": "logging.StreamHandler",
        "formatter": "verbose",
    },
    'console': {
        'level': 'DEBUG',
        'filters': ['require_debug_true'],
        'class': 'logging.StreamHandler',
        'formatter': 'verbose'
    },
    'syslog': {
        'level': 'DEBUG',
        'filters': ['require_debug_true'],
        "class": "logging.handlers.SysLogHandler",
        'formatter': 'verbose'
    },
    'sentry': {
        'level': 'ERROR',  # To capture more than ERROR, change to WARNING, INFO, etc.
        'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler'
    },
    'django.server': DEFAULT_LOGGING['handlers']['django.server'],
},
'loggers': {
    # default for all undefined Python modules, root logger
    # '': {
    #     'level': 'WARNING',
    #     'handlers': ['console', 'sentry', 'file'],
    #     'propagate': False,  # The root logger will log parent and child's logs to handlers
    # },
    'django': {
        'level': 'WARNING',
        'handlers': ['console'],
        'propagate': False,  # The log will propagate to root logger
    },

    # Default runserver request logging
    'django.server': {
        'handlers': ['django.server'],
        'level': 'DEBUG',
        'propagate': False,
    },
    'django.request': {
        'handlers': ['console'],
        'level': 'DEBUG',
        'propagate': False,  # The log will propagate to root logger
    },
    "celery": {
        "handlers": ['celery_console', 'sentry'],
        "level": "DEBUG"
    },
    “one.app": {
        "handlers": ['console', 'sentry', 'syslog', 'app_file'],
        "level": "DEBUG"
    }
}

}

这些是INFO级别的日志,HTTPD日志中的HTTPD将该日志记录为错误。

Thu Dec 06 03:35:58.591003 2018] [:error] [pid 4820] one.app     : 2018-12-06 03:35:58,590 INFO     one.api.sig:create_event_message:30 [4820:140540654921472] Update event : XYZ

[Thu Dec 06 03:37:00.026250 2018] [:error] [pid 4821] one.app     : 2018-12-06 03:37:00,026 INFO     one.api.sig:create_event_message:30 [4821:140540629743360] Update event : ABC

0 个答案:

没有答案