如何在GAE Python logging.info日志中获取文件名和行号?

gsi*_*nha 5 python google-app-engine python-2.7

在日志中,时间戳可用,但是"source file name""line number"不会记录每条日志消息.

如何在GAE Python的日志文件名和行号logging.info(或logging.warnlogging.error和其他)?

通过"source file name",我的意思是它产生的日志Python代码文件(*的.py).

nic*_*har 0

您是否尝试过查看日志格式化程序

它应该看起来像这样

formatter = logging.Formatter(
    '[%(asctime)s] p%(process)s {%(pathname)s:%(lineno)d}'
    ' %(levelname)s - %(message)s','%m-%d %H:%M:%S')
Run Code Online (Sandbox Code Playgroud)