Is there any way to config flask app.logger from a configure file, like:
logging.config.fileConfig('/path/to/logging.cfg')
or
logging.config.dictConfig(config_dict)
So i can use app.logger.info('some message')
to log both in develop and product mode.
You need to call app.logger
first and then logging.config.dictConfig(config_dict)
. The logger name should be the same in config_dict and in app.logger_name
Change logging
on line 22 to app.logger
- that will configure the logger for your current Flask app. Alternately, you can use the logging module's getLogger
function and use app.logger_name
to pull the correct logger.
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