python logging to stdout in git bash

只愿长相守 提交于 2019-12-24 14:33:25

问题


I have a python script with logging that outputs to stdout

logger = logging.getLogger()
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(v_level)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)

It works just fine when I run my script on my linux box, but when I run the script in git-bash on windows, there is no output to the console.

Any thoughts?


回答1:


Going by the information in this question, it looks like this could well be an issue with output buffering. You can skip buffering by running your script with python -u.



来源:https://stackoverflow.com/questions/35657355/python-logging-to-stdout-in-git-bash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!