django - 如何将日志记录写入现有的错误日志文件
问题描述
我的 django 错误写入的错误日志是高度可访问的。因此,在我的代码中,我想使用同一个文件进行日志记录。我的配置看起来像这样。
设置.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 文件。你能看到我错过了什么吗?
谢谢!
解决方案
推荐阅读
- r - 如何使用 ggplot2 中使用的 mean_CI_boot 计算自举置信区间?
- python - 为什么我收到此消息无效语法?
- scala - 如何以最有效的方式删除 spark RDD 的标题行?
- c - 设计带有分叉的多客户端服务器
- api - AppleScript 不起作用,安装了 JSON Helper
- spring - 使用 spring boot 和 h2 读取数据库对象
- c# - 使用 Selenium C# 单击网页上更新的最近链接
- email - 如何格式化 DKIM 标题和正文?
- c - C中的逗号运算符和后缀
- html - 使左浮动 div 在容器内中断(CSS 或 Javascript)