frnhr
frnhr

Reputation: 12903

Documentation of appropriate use for each logging level in python

I'm having trouble finding an authoritative reference which describes correct usage for each of the five logging levels in Python (DEBUG, INFO, WARNING, ERROR, CRITICAL). The docs are not specifying it:

Also found a few blogs with some personal opinions, but nothing "official" that could for example serve to settle a difference of opinions.

Is there such a reference out there?

Upvotes: 2

Views: 57

Answers (2)

Serge Ballesta
Serge Ballesta

Reputation: 149145

Those level are not specific to Python logging but are common to most logging system and originate from Unix syslog. They can be adjusted per application or system, but the common usage is:

  • DEBUG: message that should not be used in normal usage but can help to debug the application. Typically milestones in a chained processing to more easily find where an error occurs
  • NOTICE: normal messages that should always be present. Typically start and stop of an application or a subsystem
  • WARNING: abnormal condition but the processing could continue. Typically space becoming low on a disk device or a function detected incorrect characters in a field but could use a fallback strategy
  • ERROR: an operation could not be processed but the application can continue to process other operations. Typically an invalid value was detected and lead to an transaction abort
  • CRITICAL: the application cannot continue. Typically the connection to the database was lost and could not be recovered, or a disk cannot be reached...

Upvotes: 0

Vinay Sajip
Vinay Sajip

Reputation: 99495

The docs do specify this information. See here. Be sure to read the whole of the section.

Upvotes: 2

Related Questions