docker中的python logger不工作 [英] python logger in docker is not working

查看:274
本文介绍了docker中的python logger不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在docker上使用我的python应用程序。我正在使用一个名为 autologging 的软件包,其实际上是使用python的日志记录库。

I am trying to use my python app on docker. I'm using a package called autologging which is actually using python's logging library.

当我在Docker容器中使用我的应用程序时,它打印出系统打印,而不是由记录器生成的。

When I use my app inside a docker container it prints out the sys prints but not the ones generated by the logger.

compose.yml 文件中定义以下内容,但仍然无法使用:

I have tried to define the following in the compose.yml file and it's still not working:

stdin_open: True
tty: True
privileged: True
cap_add: 
 - "ALL"
environment: 
 - PYTHONUNBUFFERED=0   

我还尝试了 -u 选项。 >

I also tried the -u option.

推荐答案

自动登录模块使用Python的标准日志记录模块。因此,它由相同的配置设置控制。如果您没有看到任何日志输出,请确保您正在为应用程序正确配置日志记录。 (我自己对Docker不熟悉,根本的记录器默认情况下可能会压制日志条目)。

The autologging module uses Python's standard logging module. As such, it is governed by the same configuration settings. If you are simply not seeing any log output, please make sure that you are configuring logging appropriately for the application. (I myself am not familiar with Docker; it may simply be the case that the root logger is by default suppressing the log entries.)

如果没有明确配置请记录您的应用程序,请参阅Python文档此处。如果您有明确配置的应用程序日志记录,请提供详细信息(有一个公开的问题可以在 https://github.com/mzipay/Autologging/issues/1 )。

If you haven't explicitly configured logging for your application, please refer to the Python documentation here. If you have explicitly configured logging for your application, please provide details (there is an open issue to track this at https://github.com/mzipay/Autologging/issues/1).

(注意:我作为自动记录的作者。)

这篇关于docker中的python logger不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆