作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在日志中,时间戳可用,但“源文件名”
和“行号”
并未随每条日志消息一起记录。
如何在 GAE Python logging.info
(或 logging.warn
或 logging.error
等)中记录文件名和行号?
“源文件名”
是指生成日志的 Python 代码文件 (*.py)。
最佳答案
在你的 main.py
添加:
formatter = logging.Formatter('%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')
logging.getLogger().handlers[0].setFormatter(formatter)
关于python - 如何在 GAE Python logging.info 日志中包含文件名和行号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27456005/
我是一名优秀的程序员,十分优秀!