1
fmtter = logging.Formatter('%(asctime)s,%(msecs)05.1f (%(funcName)s) %(message)s', '%H:%M:%S')

rock_log = '%s/rock.log' % Build.path
hdlr = logging.FileHandler(rock_log, mode='w')
hdlr.setFormatter(fmtter)
hdlr.setLevel(logging.DEBUG)

rock_logger = logging.getLogger('rock')
rock_logger.addHandler(hdlr)

I have the above logger

rock_logger.info("hi") doesnt print anything to the log BUT
rock_logger.error("hi") DOES print to the log

I think it has something to do with level but i specifically set it to logging.DEBUG

Anyone know what I am doing wrong?

ealeon
  • 12,074
  • 24
  • 92
  • 173

1 Answers1

2

In your case rock_logger is the logger and hdlr is the handler. When you try to log something, the logger first checks if it should handle the message (depending on it's own log level). Then it passes the message to the handler. The handler then checks the level against it's own log level and decided whether to write it to the file or not.

Your rock_logger might have the logging level set to errors. So it's not passing the messages to the handler when you try info() or debug().

rock_logger.setLevel(logging.DEBUG)

That should fix the issue.

masnun
  • 11,635
  • 4
  • 39
  • 50