0

I'm following the excellent blog series: The Flask Mega-Tutorial https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-error-handling and trying to write an error message to logger in app/main/routes.py using:

app.logger.error("Encountered an error here!")

I couldn't find an example in the blog series of where error messages were being logged. How do you import app.logger in to app/main/routes.py that was defined in app/__init__.py?

FarNorth
  • 261
  • 1
  • 5
  • 15
  • as far as I know `flask` uses the built-in Python `logging` module which as far as I have seen seems to be global, meaning that configuring it in one file will have effect on all linked files (if `logging` is imported), [some official docs](https://docs.python.org/3/howto/logging.html) and a [related question](https://stackoverflow.com/questions/7621897/python-logging-module-globally)(particularly the 2nd answer?). about importing, if `app` is a package then simply use `from app import whatever` tho I don't think this is how logging is supposed to be imported, might be wrong – Matiiss Aug 13 '21 at 19:43

0 Answers0