I'm trying to use the logging module for python (2.6), whenever I try to use one of the handlers however it claims it doesn't exist. For example

import logging.handlers.SMTPHandler

Gives me the error

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named SMTPHandler

I managed to find the handlers.py code in the python libraries, and the code does exist for all of the handlers, so I'm not really sure what's going on?

Recommended Answers

All 2 Replies

The problem is that logging.handlers.SMTPHandler is not a module but a class. You must write

from logging.handlers import SMTPHandler

Thanks :)

Edit: NM fixed it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.