Python logging in a Zope product (how to)

I noticed that zLOG is now deprecated and the deprecation message said to use standard Python logging.

One way I found to get this working was to add the following to my module .py file in the product:

import logging
LOG = logging.getLogger("mymodule")

Then you can use LOG.error("foo") to send log messages. To see the "mymodule" identifier in the logs you may want to modify your zope.conf file like so:

<eventlog> level debug <logfile>

path $INSTANCE/log/event.log
level debug
format %(asctime)s %(name)-12s %(levelname)-8s %(message)s

</logfile> </eventlog>

Now I can see log messages and don't get a deprecation warning about it. Yay.

archived on 2006-04-02 in

blog comments powered by Disqus