What are others doing for application logging? I'm not referring to the
HTTP logs, but program-generated logs.

I've recently been looking at the Python 'logging' module, which I've not
used before. I initiate logging from a file in the 'modules' directory
which does this:

--------------------------------------------------------------------------------
import logging
from logging.handlers import SysLogHandler

logger = logging.getLogger("MyApp")
logger.setLevel(logging.DEBUG)
hdlr = SysLogHandler(address='/dev/log')
formatter = logging.Formatter('tigerpy[%(process)d]: %(levelname)s:
%(filename)s at line %(lineno)d: %(message)s') hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
--------------------------------------------------------------------------------

Then each file that I want to log from does this:

--------------------------------------------------------------------------------
import logging

logger = logging.getLogger("MyApp")
.
.
logger.info("Something interesting happened")
--------------------------------------------------------------------------------

This logs to syslog: the only problem is that each logging message is
written to syslog many (20-40) times(!). This isn't just in one place in
my code, but throughout. I don't think the code is being executed multiple
times, so I'm not sure why I'm getting so many log entries.

So, I'm interested in what others do to log application events.


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en

Reply via email to