I'd be interested in a step by step guide to setting up this kind of
logging. I'm new to web2py and python and I think it would help my
learning.

I already get some good info by monitoring the http log file with the
free Kiwi log viewer (on Windows) which tails the file.

Could someone explain step by step how to set up the Python logging
module to write to a file from a web2py application.  Thanks!

On Apr 17, 8:37 pm, Keith Edmunds <[email protected]> wrote:
> 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