# Background logger
NEW in v22.9
The background logger requires both
You can setup Sanic Extensions to log all of your messages from a background process. This requires that you not be in single process mode.
Logging can sometimes be an expensive operation. By pushing all logging off to a background process, you can potentially gain some performance benefits.
Out of the box, the background logger is disabled. You will need to opt-in if you would like to use it.
app.config.LOGGING = True
# How does it work
When enabled, the extension will create a
multoprocessing.Queue. It will remove all handlers on the default Sanic loggers and replace them with a
QueueHandler (opens new window). When a message is logged, it will be pushed into the queue by the handler, and read by the background process to the log handlers that were originally in place. This means you can still configure logging as normal and it should "just work."
|LOGGING|| || ||Whether to enable this extension.|
|LOGGING_QUEUE_MAX_SIZE|| || ||The max size of the queue before messages are rejected.|