On Monday 09 June 2014 12:40:43 alonn wrote:
> Seems that Django loggers default to use stderr for **all** logging levels.
>
I think this is a Python stdlib issue; I don't think Django is doing anything
special here.
> for example when logging setup is:
>
> 'handlers': {
> 'console': {
> 'level': 'DEBUG',
> 'class': 'logging.StreamHandler',
> 'formatter': 'default',
>
> }
> },
> When I change handlers to:
>
> 'handlers': {
> 'console': {
> 'level': 'DEBUG',
> 'class': 'logging.StreamHandler',
> 'formatter': 'default',
> 'stream': sys.stdout #Notice the change
> }
> },
>
> Then all output is in stdout.
>
What you see here is documented behavior:
https://docs.python.org/2/library/logging.handlers.html#streamhandler
> But I need the **correct** behavior: logging info,debug, warning to
> ```stdout``` (warning can go either way, don't really care) and exception,
> error, critical to ```stderr```
>
I don't think I'd call that **correct**.
> What am I missing here? (some obvious setting? everybody knows about?)
You are, essentially, asking for a handler that only emits messages *under* a
given severity level. I don't think the Python logging framework supports
that.
If that is really what you want, subclassing logging.StreamHandler should not
be too hard; however, I doubt your spec.
Shai.