我的django错误被写入的错误日志是高度可访问的。结果,在我的代码中,我想使用同一文件进行日志记录。我的配置如下所示。
Settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'ERROR',
'class': 'logging.FileHandler',
'filename': '/opt/python/log/djangoerrors.log'
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'ERROR',
'propagate': True,
},
},
}
在我看来,我已经做到了:
import logging
logger = logging.getLogger(__name__)
def myview(request):
... some code ...
logger.error('hello. This should be logged to the error file.')
不幸的是,该文本未写入我的djangoerrors.log文件。可以看到我想念的东西吗?
谢谢!