Sanic currently supports Linux log directory as /dev/log, and the log wouldn't work if the directory does not exist. How do I change the directory to a custom one?
Sanic uses the regular standard library logging
utility.
Per the documentation:
To use your own logging config, simply use
logging.config.dictConfig
, or passlog_config
when you initializeSanic
app.
app = Sanic('test', log_config=LOGGING_CONFIG)
# or
logging.config.dictConfig(LOGGING_CONFIG)
Here is a good resource on logging in Python.
What you are looking for is the filename
keyword.
LOGGING_CONFIG = {
...
'filename': '/path/to/my/log'
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With