Friday 10 June 2011

Logging - simple mistake

I recently ran into a problem where my logging started to duplicate each log message, but in a different format after one particular logging call.

I could not track down the error, until I actually read what I wrote:


import logging

logger = logging.getLogger("a.logger")

class Something:
...
logging.debug("a message")


I'd accidentally called debug on the logging module, not my logger. Everything I was googling was pointing towards enabling the default logging config (e.g.
logging.basicConfig()
) but I hadn't done so.

Easy mistake to make, thought I'd briefly write about it.

1 comment:

  1. how about a plugin api, that would be nice

    ReplyDelete