[mod_python] outputting to apache log

greg girty at cogeco.ca
Tue Jul 11 12:01:14 EDT 2006


> There is "req.log_error()" and "apache.log_error()" but their output
> goes to the "error_log" file. I also don't know of anyway from
> mod_python of making stuff go to the "access_log".
> 
> Remember the "access_log" has a specific format which can be changed
> based on various Apache log directives and a lot of tools also expect to
> process "access_log". Dumping arbitrary stuff in there may cause
> problems for such tools. That is I presume why very basic logging
> functions go to "error_log" instead. There may well be a Apache C API
> for putting stuff in "access_log" but it is probably going to have a
> very restricted interface and not allow arbitrary messages. You would
> need to do some digging through Apache C API to find if such a one
> exists and even if it is meant to be used by user code and Apache is
> going to call it for you anyway.
> 
> 
>>If there is no modpy specific way of doing it, is there a generic
>>approach in apache to capture stdout from a script?
> 
> 
> Anything sent to sys.stdout and sys.stderr streams may eventually end up
> in "error_log" but the streams generally need to be flushed explicitly
> to get them to come out at instant that they are used rather than
> sometime later when the streams are flushed by something else.
> This may dependent on platform though.
> 
> What are you trying to log, general debug logging or something
> analogous to what is in "access_log" now but perhaps to some other
> location?

Thanks again Graham.

In answer to your question, I have some information about visitor's form 
choices that statys with them in a session. I want to correlate that to 
page views, and pretty-print it. My next attempt will be to save it in a 
session, and dump it to a custom log in the LogHandler (syscall to cat), 
and teach AWStats to read the custom file format.

Greg.


More information about the Mod_python mailing list