dabeaz-course/practical-python

8.2 Logging, Ex 8.3: had to use the setLevel() method instead of .level=

Closed this issue · 1 comments

I am using Python 3.8.9. and the following code (near the end of Ex 8.3 of the 8.2 Logging page):

logging.getLogger().level = logging.DEBUG
a = report.read_portfolio('Data/missing.csv')

did not appear to change the logging level from warning to debug on my system, as it only output the warning messages. Using the setLevel() method instead as follows:

logging.getLogger('fileparse').setLevel(logging.DEBUG)
a = report.read_portfolio('Data/missing.csv')

fixed this for me and correctly displayed both the debug, and warning messages. A similar change was also needed to change the level to critical.

I'm not sure if this is because of the version I have, or something else, but I thought I should mention this.

Fixed.