How can I stop sys.stdout logging to apache error

2019-08-13 07:45发布

问题:

I have the Python logging library set up to log everything to my console handler. This works great in development so I can see my log messages without having to look through the files but in production all of the logs are being written to the apache error file.

Is this desired behaviour? Shouldn't stderr solely write to the error file?

The console handler set up in my yaml config file:

handlers:
  console:
    class: logging.StreamHandler
    formatter: precise
    filters: [request_id]
    stream: ext://sys.stdout

I have thought about only adding the console handler in debug mode, but I have lots of loggers with propagate set to false, so I would have to add the handler to each logger which defeats the point of my config file.

I have put the entire config file into pastebin.

How can I stop stdout writing to the Apache error file and could this have adverse effects?