If your script communicates its output through text, you should use stdout to print this output. Users can use pipes to save this output to a file, or you can accept an optional -o argument. Everything else should be written to stderr using the logging module.
It is good practice to redirect all error messages to stderr , while directing regular output to stdout . It is beneficial to do this because anything written to stderr is not buffered, i.e., it is immediately written to the screen so that the user can be warned immediately.
The stdout. log file is a console logging file that has poor log management which causes the file to grow too large. PROBLEM DESCRIPTION. From PingFederate 9.0 onwards: 1) If an OS service start up script is being used or <pfinstall>/sbin/pingfederate-run.sh, output can be sent to stdout.
stdout − It stands for standard output, and is used to text output of any command you type in the terminal, and then that output is stored in the stdout stream. stderr − It stands for standard error. It is invoked whenever a command faces an error, then that error message gets stored in this data stream.
Regular output (the actual result of running the program) should go on stdout
, things like you mentioned (e.g. diagnostic, notice, warning, error) on stderr
.
If there is no "regular output", I would say that it doesn't really matter which one you choose. You could argue that the logging is the only output, so that should go to stdout
. Or you could argue that it is still "exceptional information" which should go to stderr
.
Do you write something else to stdout
? If the answer is Yes
then it would be quite hard for someone to distinguish between normal flow and errors in the middle of the file that was used to redirect from stdout
.
What if stdout
will be used as input for another program? Will it be able to parse this debug information? In this case it would be good to write only critical errors to stderr
. If you need to write something else you may consider to write to additional log file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With