How to configure app.logger flash drive from configuration file?

Is there a way to configure the app.logger flag from the configuration file, for example:

logging.config.fileConfig('/path/to/logging.cfg') 

or

 logging.config.dictConfig(config_dict) 

Therefore, I can use app.logger.info('some message') to register both in development mode and product mode.

+6
source share
2 answers

First you need to call app.logger , and then logging.config.dictConfig(config_dict) . The registrar name must be the same in config_dict and in app.logger_name

+4
source

Change logging on line 22 to app.logger - this will configure the logger for the current Flask application. Alternatively, you can use the logging getLogger module and use app.logger_name to pull out the correct logger.

+1
source

Source: https://habr.com/ru/post/922155/


All Articles