views:

812

answers:

3

I seem to only be able to write to the Apache error log via stderr. Anyone know of a more structured logging architecture that I could use from my python web project, like commons?

+2  A: 

I've used the builtin Python logging module in (non-web) projects in the past, with success - it should work in a web-hosted environment as well.

Blair Conrad
+2  A: 

There isn't any built in support for mod_python logging to Apache currently. If you really want to work within the Apache logs you can check out this thread (make sure you get the second version of the posted code, rather than the first):

If you're just looking to use a more structured logging system, the Python standard logging module referred to by Blair is very feature complete. Aside from the Python.org docs Blair linked, here's a more in-depth look at the module's features from onLamp:

And for a quickie example usage:

Jay
A: 

I concur with Blair Conrad's post about the Python logging module. The standard log handlers sometimes drop messages however. It's worth using the logging module's SocketHandler and building a receiver to listen for messages and write them to file.

Here's mine: Example SocketHandler receiver.

Ben Godfrey