Using with Django#
Django has a default logging configuration that executes when the application initializes.
This configuration is defined in the LOGGING
variable in the settings.py
file. By default, Django will
configure a set of streaming loggers from the standard library logging module.
To use picologging with Django, you need to change some settings.
Set
LOGGING_CONFIG
toNone
insettings.py
. This will prevent Django from configuring the default logging system.Change the handler classes from
logging.xxx
topicologging.xxx
, e.g.logging.StreamHandler
topicologging.StreamHandler
.Call
picologging.config.dictConfig(LOGGING)
insettings.py
to configure picologging.Change your imports where logging is used to
`import picologging as logging
.
Here is a complete example of settings.py
Then in a view to use those loggers: