使Django Logger为我创建日志文件

时间:2018-07-19 02:16:02

标签: python django logging

我的记录器设置如下:

...'handlers': {
    # with debug on, print log messages to the console
    'console': {
        'level': 'DEBUG',  # error message level
        'filters': ['require_debug_true'],  # choose filter
        'class': 'logging.StreamHandler',  # iostreams
        'formatter': 'verbose'  # format of messages
    },
    # with debug on, log messages in dev file
    'development_logfile': {
        'level': 'DEBUG',
        'filters': ['require_debug_true'],
        'class': 'logging.FileHandler',  # open and close files
        'filename': '/Users/Michael/venvs/wabi/wabi_clean/dev.log'),
        'formatter': 'verbose'
    },
    # with debug off, log messages in prod file
    'production_logfile': {
        'level': 'ERROR',
        'filters': ['require_debug_false'],
        'class': 'logging.handlers.RotatingFileHandler',  # have file backups
        'filename': os.path.join(BASE_DIR, 'prod.log'),
        'maxBytes': 1024*1024*100,  # 100MB (max file size)
        'backupCount': 5,  # number of backup files
        'formatter': 'simple'
    },
    'dba_logfile': {
        'level': 'DEBUG',
        'filters': ['require_debug_false', 'require_debug_true'],
        'class': 'logging.handlers.WatchedFileHandler',  # read into more
        'filename': os.path.join(BASE_DIR, 'dba.log'),
        'formatter': 'simple'
    },...

'filename': os.path.join(BASE_DIR, 'prod.log'),的地方不起作用。我需要为已经存在的文件添加完整路径。

我在做什么错了?

0 个答案:

没有答案