tags:

views:

174

answers:

1

What is the recommended way to log application-specific messages in web2py? I found the documentation on HTTP logging, but I'm thinking more of messages for debugging and tracking.

Should I simply use the logging module in each separate controller file? Is there a central place in which I could initialize a logger that can be shared between controllers? Or, is something built-in to web2py that I should use?

Update: It looks like I can't even fully use the logging module in web2py. It looks like web2py ships with it's own version of the python libraries (in library.zip), which I'm not a big fan of. Is that by design? I'm guessing there will be issues with simply adding my installed Python libraries to the sys.path at run-time, so what should I do?

A: 

http://www.mail-archive.com/[email protected]/msg35964.html

mdipierro
It looks like the posters in that thread have no trouble importing loggingl.handlers. For me, "import logging.handlers" throws an "ImportError: No module named handlers" exception.Interestingl, a basic "import logging logging.debug('A debug message')" doesn't even work, while "print 'foo'" does.
MikeWyatt
This was apparently a problem with the goofy subset of the Python standard lib that is included with the web2py binary distribution. I'm able to running my server from the web2py source and use logging.handlers without issue.
MikeWyatt
the web2py binary distribution includes all standard Python 2.5 modules. You may want to run from source anyway. import logging should work fine (most users use it). If there is a problem bring it up on the web2py mailing list and we will help resolve it.
mdipierro