Robert Brewer wrote:
Kamus of Kadizhar wrote:

I'm having a problem with logging.  I have an older app that used the
RotatingFileHandler before it became part of the main distribution (I
guess in 2.3).
[snip]
The offending snippet of code is:

logFile = logging.handlers.RotatingFileHandler('/var/log/user/movies2.lo
g','a',2000,4)
logFile.emit(movieName)


Making a quick run-through of the logging module, it looks like you need
to have a Formatter object added to your Handler:

filename = '/var/log/user/movies2.log'
logFile = logging.handlers.RotatingFileHandler(filename,'a',2000,4)
formatter = logging.Formatter()
logFile.setFormatter(formatter)

...then you can call emit.

Of course, you should not normally be calling emit() from user code. The correct approach is to log events to loggers, and not emit them to handlers directly.


Best regards,


Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list

Reply via email to