web2py application logging
Asked Answered
U

2

6

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?

Untouchability answered 21/5, 2010 at 15:0 Comment(0)
T
2

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

Toulon answered 21/5, 2010 at 18:47 Comment(3)
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.Untouchability
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.Untouchability
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.Toulon
Q
7

Here it is described in detail how to do it.

Quantic answered 25/4, 2011 at 6:47 Comment(0)
T
2

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

Toulon answered 21/5, 2010 at 18:47 Comment(3)
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.Untouchability
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.Untouchability
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.Toulon

© 2022 - 2024 — McMap. All rights reserved.