How to get logger level as string value

Solution 1:

If you place the result of a call to the object's getEffectiveLevel() method into the logging module's getLevelName() class method, you get returned to you the string representation of the level:

import logging

log = logging.getLogger('blah')
str_level = logging.getLevelName(log.getEffectiveLevel())

print(str_level)

Output:

WARNING