Should I log messages to stderr or stdout?

后端 未结 2 886
攒了一身酷
攒了一身酷 2020-12-25 09:13

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

2条回答
  •  执念已碎
    2020-12-25 10:14

    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.

提交回复
热议问题