# When to Use Different Log Levels This note comprises some heuristics others and myself have found success with when it comes to deciding when and how to use the different log levels in a logging utility. ## Debug - Every logged class method should log that it was called as DEBUG along with its parameters. - You should be able to pretty much recreate all that happened with DEBUG logs. ## Info - API or external system calls should be logged, at least at this level. Log the start and end times of each call to get an idea of how long that call takes. - At this level, you shuold be able to tell whether it ran reasonably and see what choices might have been made. ## Warn - Any time an exception is handled ## Sources > 1. Every method of any class I've built logs that it's called as DEBUG; I'll often include whatever variables were passed to it. This way in debug mode I can see every step of the process 2. API calls or other interactions with external systems definitely should be logged, probably at INFO level at least. Log when it starts and when it ends. This way you can tell about how long it took. 3. Clearly any time you handle an exception that's a good WARNING, because something happened that needed managing. If I look at the log at DEBUG level, I should be able to pretty much recreate everything that happened. Clearly this is helpful, but it's also a lot of junk, so it can be annoying. At the INFO level I should be able to tell whether it ran reasonably, and I should be able to see choices that were made (e.g. did it choose to do calculation A or calculation B? which toggle did they select before saying "next"?). And of course the best way to tell what needs logging is that you ran your code and thought to yourself "I wonder if. . . ". You should log that thing you wondered. https://reddit.com/r/learnpython/comments/v9judz/_/ibxnuv1/?context=1