Loguru: unexpected behavior writing to stderr

Created on 17 Apr 2019  路  4Comments  路  Source: Delgan/loguru

First, I really like the idea behind loguru.

Why is the default logger logging to stderr? and not stdout? Can you add a paragraph explaining this choice?

docs question

Most helpful comment

Hello @oz123.

Actually, I made this choice without thinking too much about this, mainly because logging to stderr rather than stdout seems to be a widely accepted convention.

For example, logging.basicConfig() and logging.StreamHandler defaults to stderr. Also, the POSIX standard specifies that stderr is the correct stream for "diagnostic output".

The main compelling case in favor or logging to stderr in my opinion is that is avoid mixing the actual output of your application with debug information of your logs. Consider for example pipe-redirection like python my_app.py | other_app which would not be possible if logs were emitted to stdout.

All 4 comments

Hello @oz123.

Actually, I made this choice without thinking too much about this, mainly because logging to stderr rather than stdout seems to be a widely accepted convention.

For example, logging.basicConfig() and logging.StreamHandler defaults to stderr. Also, the POSIX standard specifies that stderr is the correct stream for "diagnostic output".

The main compelling case in favor or logging to stderr in my opinion is that is avoid mixing the actual output of your application with debug information of your logs. Consider for example pipe-redirection like python my_app.py | other_app which would not be possible if logs were emitted to stdout.

@Delgan, thanks for taking the time to answer this question. I really appreciate it. This detailed answer is really helpful.

Sure, no problem. 馃憤

I will add some words about this choice in the documentation.

I added a paragraph near the top of the documentation, explaining rational behind this choice. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

af6140 picture af6140  路  5Comments

yoonghm picture yoonghm  路  3Comments

volfco picture volfco  路  5Comments

HarveySummers picture HarveySummers  路  4Comments

lvar picture lvar  路  6Comments