如何在GAE Python logging.info日志中设置文件名和行号?
在日志中,时间戳可用,但并非每个日志消息都会记录如何在GAE Python logging.info日志中设置文件名和行号?,python,google-app-engine,python-2.7,Python,Google App Engine,Python 2.7,在日志中,时间戳可用,但并非每个日志消息都会记录“源文件名”和“行号” 如何在GAE Python中记录文件名和行号logging.info(或logging.warn或logging.error和其他) 通过“源文件名”,我指的是生成日志的Python代码文件(*.py) 你试过看吗 应该是这样的 formatter = logging.Formatter( '[%(asctime)s] p%(process)s {%(pathname)s:%(lineno)d}' ' %(l
“源文件名”
和“行号”
如何在GAE Python中记录文件名和行号logging.info
(或logging.warn
或logging.error
和其他)
通过“源文件名”
,我指的是生成日志的Python代码文件(*.py) 你试过看吗
应该是这样的
formatter = logging.Formatter(
'[%(asctime)s] p%(process)s {%(pathname)s:%(lineno)d}'
' %(levelname)s - %(message)s','%m-%d %H:%M:%S')
在
main.py中添加:
formatter = logging.Formatter('%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')
logging.getLogger().handlers[0].setFormatter(formatter)