Making logging.getLogger() simpler
Lie Ryan
lie.1296 at gmail.com
Sat Sep 18 12:35:15 EDT 2010
I was expecting this to work:
import logging
logger = logging.getLogger(__name__)
logger.warn('this is a warning')
instead it produced the error:
No handlers could be found for logger "__main__"
However, if instead I do:
import logging
logging.warn('creating logger')
logger = logging.getLogger(__name__)
logger.warn('this is a warning')
then it does work.
Is there any reason why getLogger()-created logger shouldn't
automatically create a default handler?
More information about the Python-list
mailing list