我正在编写一个Glue ETL,并尝试使用Python默认的logger
进行日志记录
问题是,我正在使用记录器打印的所有日志消息都出现在作业的错误流中
如果我直接打印到stdout(使用print
),我会在常规cloudwatch日志流中看到打印的消息
我试图将日志重定向到标准输出,但仍然得到相同的结果:错误流中出现消息
有人知道我如何使用logger,并且仍然可以在log cloudwatch流中看到我的消息吗?(并且不在错误cloudwatch流中)
这是我用来测试的代码示例:
import logging
import sys
MSG_FORMAT = '%(asctime)s %(levelname)s %(name)s: %(message)s'
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(format=MSG_FORMAT, datefmt=DATETIME_FORMAT, stream=sys.stdout)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.info("Test log message. This appear on the job error cloudwatch stream")
print("This is a print. This appear on the job log cloudwatch stream")
我最后加了
根据我的定义。 这就解决了问题
相关问题 更多 >
编程相关推荐