How to show logs in a flask app

Hello,
I have a flask server

at the beginning I put this:

root = logging.getLogger()
root.setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)

then in the code :

 logging.info("edges :", edges)

Why I do not see the logs?

Hi there,

I think you need to add app.logger.setHandler(handler) to the end of this. However, I would recommend you refer to Flasks docs on how to configure logging: https://flask.palletsprojects.com/en/2.3.x/logging/.

Regards,

Keith
Render Support, UTC+10 :australia:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.