Should I log messages to stderr or stdout?

user193476 picture user193476 · Feb 7, 2011 · Viewed 10.7k times · Source

I have a program I'm writing that I want to write a custom logging facility for (e.g. diagnostic, notice, warning, error).

Should I be using the stdout or the stderr stream to do this? It is an interpreter of sorts and the user can ask it to print output.

Edit: Please stop recommending me logging frameworks :(

Answer

Jakob picture Jakob · Feb 7, 2011

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.