I have a python script. It has a SimpleLogger
with sys.stdout
as output_stream
.
logger = SimpleLogger(level=LogLevel.DEBUG)
When I run it in console, I get the logs properly, but whenever I redirect the output to a file, nothing is found in the target.
I tried multiple ways:
In both cases, the /tmp/x.log
is empty.
I also tried nohup python server.py
, but nothing has been written in nohup.out
.
This is probably just due to buffering. You will only see something in the file when enough output has been accumulated. You can try using python -u
to ask for unbuffered output, or set environment variable PYTHONUNBUFFERED=
to any non-empty string, as documented in the Python command line documentation, or add a .flush()
call after each .debug()
or similar call.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments