My flask application uses a module which gets a logger like this:
import logging
logger = logging.getLogger("XYZ")
...
logger.debug("stuff")
Without having to modify anything in the module, can I configure flask such that the module will get flask's app.logger when it makes the getLogger("XYZ") call?
The Flask logger is accessible during a request or CLI command via current_app.
Example usage:
from flask import current_app, Flask
app = Flask('HelloWorldApp')
@app.route('/')
def hello():
current_app.logger.info('Hello World!')
return "Hello World!"
if __name__ == '__main__':
app.run()
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