Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用dictConfig进行Django日志记录时找不到";日志记录“;模块_Python_Django_Logging_Python 2.6_Django 1.3 - Fatal编程技术网

Python 使用dictConfig进行Django日志记录时找不到";日志记录“;模块

Python 使用dictConfig进行Django日志记录时找不到";日志记录“;模块,python,django,logging,python-2.6,django-1.3,Python,Django,Logging,Python 2.6,Django 1.3,设置中的“我的日志记录”指令设置为: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'default': { 'format': '[%(asctime)s] %(levelname)s::(%(process)d %(thread)d)::%(module)s - %(message)s' }, },

设置中的“我的日志记录”指令设置为:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'default': {
            'format': '[%(asctime)s] %(levelname)s::(%(process)d %(thread)d)::%(module)s - %(message)s'
        },
    },
    'handlers': {
        'file_handler': {
            'level': 'DEBUG',
            'formatter':'default',
            'class': 'logging.TimedRotatingFileHandler',
            'filename':'Project_log',
            'when':'midnight',
            'interval':1
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['file_handler'],
            'level': 'DEBUG',
            'propagate': True,
        },
    }
}
根据文档示例,处理程序的类设置为logging.HandlerName:

但我收到以下错误:

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 776, in dictConfig
    dictConfigClass(config).configure()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py",     line 575, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'file_handler': Cannot resolve 'logging.TimedRotatingFileHandler': No module named TimedRotatingFileHandler
你得写

logging.handlers.TimedRotatingFileHandler

因为
TimedRotatingFileHandler
是日志处理程序包的一部分。

我刚刚签入了ipython,如果您只需要了解您需要导入的确切内容,它将是
logging.handlers.TimedRotatingFileHandler