0

I have my python logger set to debug, but it still prints out info messages:

import logging
from logging.config import fileConfig
fileConfig('./log/logging_config_serial.ini')
logger = logging.getLogger()

logger.debug("debug")
2018-10-01 09:58:43,161 root         DEBUG    debug
logger.info("info")
2018-10-01 09:58:50,997 root         INFO     info

logger.getEffectiveLevel()
Out[12]: 10

Looks like it set to debug level on the output (10=DEBUG, 20=INFO)

Here is my config file:

[loggers]
keys=root

[handlers]
keys=stream_handler,fileHandler

[formatters]
keys=formatter

[logger_root]
level=DEBUG
handlers=stream_handler,fileHandler

[handler_stream_handler]
class=StreamHandler
level=DEBUG
formatter=formatter
args=(sys.stderr,)

[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=formatter
args=("./log/l5e5_get_header_info_serial_R3.log",)

[formatter_formatter]
format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s
martineau
  • 119,623
  • 25
  • 170
  • 301
Celi Manu
  • 371
  • 2
  • 7
  • 19

1 Answers1

1

DEBUG is the lowest level so by default this will include all of the higher levels also (as by default it's assumed if you are looking at DEBUG you'll also want to see WARNINGS, INFO and ERRORs)

Sven Harris
  • 2,884
  • 1
  • 10
  • 20
  • Thanks. I thought it was the other way around. Do you know if there's a way to set DEBUG as an upper bound? – Celi Manu Oct 01 '18 at 18:23
  • 1
    I think you can use the solution outlined here to filter https://stackoverflow.com/questions/8162419/python-logging-specific-level-only – Sven Harris Oct 01 '18 at 19:15