5 ms·
Why log to stderr instead of just stdout?
by majormjr 7y ago
Why log to stderr instead of just stdout?
- ktm5j 7y agoMaybe just convention? It's standard practice to use stdout for directly interacting with a user and stderr for log/error type messages. You can redirect stderr to a file to get all of your log messages, but keep stdout available for interacting with the user. Super useful to separate meta-messages out in this manner. Here's a good blog post with more info on stderr for those interested: https://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout https://www.jstorimer.com/blogs/workingwithcode/7766119-when...
- anderspitman 7y agoMight be because stdout is buffered, so you don't always get output right away, while stderr is unbuffered.
- btashton 7y agoYou split the user interaction from the logging. In the case of the webserver maybe this a less of an issue, but if I'm processing text output from an application I don't want a log message inserting itself in the middle of the output.