Darren Cui Liang wrote: > Hi, there! > > Now I am working around with the "logging" module. Here is the code: > > > >>> import logging > >>> log1=logging.getLogger("a") > >>> log1.critical("msg") > No handlers could be found for logger "a" > >>> logging.critical("msg") > CRITICAL:root:msg > > Since every "logger" is under the "root logger", and if no handler is > found for the logger, the message will be passed to upper level loggers, > until the root, > then why do I get the msg: No handlers could be found for logger "a"
The error-message is always for the used logger - but it will search the list of its parents for appropriate handlers. So setting a handler on a logger foo makes the logger foo.bar find it. Or, alternatively, obtain a reference tto the root-logger, and set your handler there. Then all loggers will find it. Diez -- http://mail.python.org/mailman/listinfo/python-list