python日志记录模块默认在哪里写日志?

BAE*_*BAE 5 python logging jenkins

我有一个由jenkins运行的python脚本。使用日志记录模块。

logging.basicConfig(filename="/tmp/test.log",
                    format="%(asctime)s %(levelname)s %(message)s",
                    filemode="a",
                    level=logging.INFO)
Run Code Online (Sandbox Code Playgroud)

如果删除了上述配置,则无法找到以下语句生成的日志:

logging.info("xxxxxxx")
Run Code Online (Sandbox Code Playgroud)

我没有在詹金斯机的系统日志中找到它。我在jenkins控制台输出中找不到它。

有什么提示吗?谢谢

mun*_*unk 5

默认情况下,日志记录写入stderr。之所以看不到该语句,是因为默认日志级别为警告。

>>> import logging
>>> logging.error('a message!')
ERROR:root:a message!
>>> logging.warning('a message!')
WARNING:root:a message!
>>> logging.info('a message!')
>>>
Run Code Online (Sandbox Code Playgroud)