问题
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