DEV Community

Cover image for The Pythonic Guide To Logging

The Pythonic Guide To Logging

Sid Panjwani on June 25, 2018

When done properly, logs are a valuable component of your observability suite. Logs tell the story of how data has changed in your application. The...
Collapse
 
wlbentley profile image
W L Bentley • Edited

Thank you for the useful post. Just a quick correction.

Running the sample code under Logging to a File, the logger is created with a default level of WARNING, so the INFO log record is actually not written to the log file. To include it in the log file, set the logger level to INFO as well:

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Collapse
 
sidhanthp profile image
Sid Panjwani

Thanks for catching that, I'll leave a note in the article!

Collapse
 
tadaboody profile image
Tomer

Might wanna look at the docs at the app specific logger flask.pocoo.org/docs/1.0/logging/ it also shows how to do some useful stuff like access library loggers and such

Collapse
 
kmehran1106 profile image
Mehran Kader

really a nice write :D would have helped me a lot if I found this a few weeks back :p