[mod_python] loglevel

Graham Dumpleton grahamd at dscpl.com.au
Sat Nov 11 20:06:36 EST 2006


On 12/11/2006, at 4:38 AM, julien coron wrote:
> I would like to log my python handler only, not Apache.

If you want to do something that isn't normal, then don't expect it
to do what you want. ;-)

> There is also no output when I try to do "print 'this is a log  
> message' ".

Correct. You shouldn't use 'print' in handlers as stdout stream of  
Apache
isn't guaranteed to go anywhere. If you go sys.stdout.flush() after
using 'print', if you are lucky it will end up in the Apache error log.

Where were you expecting it to go? Remember that Apache is generally
run as a daemon process and so it doesn't have a terminal to output
stuff to.

> The next try will be to use an other logger to manage that.

You probably want to investigate the 'logging' module in Python. If you
use that to log messages, you can then provide your own log handler
which logs either to the Apache error log file or to some other file of
your own. If you search the Internet properly, am sure you will find
examples of log handlers for log files already. There may even be one
in the logging module for all I know. In doing a separate log file  
through,
release that the logging system you use must support multiple processes
logging to it at the same time.

> Thanks,
> Julien
>
> Le 10 nov. 06 à 18:44, Martin Stoufer a écrit :
>
>> As I recall, the apache.log_error() method is a direct wrapper to  
>> the Apache logging API.   By setting the LogLevel to 'debug'  in  
>> httpd.conf, you should be seeing all messages. If you have it set  
>> at 'error', you will be ignoring "info" logged from mod_python.
>>
>> I have not seen anything inside mod_python that will allow you  
>> arbitrarily set a logging level threshold.
>>
>> BTW, are you logging to the syslog mechanism, or to the apache  
>> logs? There may be a block in the syslog.conf dropping the messages.
>>
>> julien.coron at free.fr wrote:
>>> Hi Martin,
>>>
>>> Allright for the loglevel, but is there a way to set the loglevel  
>>> of apache to
>>> "error" and the loglevel of mod_python to "info" ?
>>>
>>>
>>>
>>>
>>> Selon Martin Stoufer <MCStoufer at lbl.gov>:
>>>
>>>
>>>> Julien,
>>>>     This is stored in the httpd.conf file for apache. Look for
>>>> "LogLevel" and change it so it includes the 'error' level. You  
>>>> may also
>>>> want to look at any specialized logging parameters for the  
>>>> Directory you
>>>> are serving content from. For this look for the "LogFormat".  
>>>> Someone may
>>>> have redirected error messages to another log file.
>>>>
>>>>
>>>>
>>>> julien.coron at free.fr wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I want to send some messages to the log file, but none under  
>>>>> "error" are
>>>>>
>>>> traced:
>>>>
>>>>> apache.log_error("This is an ERROR", apache.APLOG_ERR)
>>>>> apache.log_error("This is an INFO", apache.APLOG_INFO)
>>>>> apache.log_error("This is a DEBUG", apache.APLOG_DEBUG)
>>>>>
>>>>> ...even if I set the loglevel of apache to "debug".
>>>>>
>>>>>
>>>>> Is there a way to set the loglevel of mod_python to "debug" and  
>>>>> the apache
>>>>>
>>>> one
>>>>
>>>>> to "error" ?
>>>>>
>>>>>
>>>>> Julien CORON
>>>>> _______________________________________________
>>>>> Mod_python mailing list
>>>>> Mod_python at modpython.org
>>>>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>>>>
>>>>>
>>>> --
>>>> * Martin C. Stoufer              *
>>>> * DST/DIDC/ITG                   *
>>>> * Lawrence Berkeley National Lab *
>>>> * MS 50B-2239 510-486-8662       *
>>>>
>>>>
>>>>
>>>
>>>
>>
>> -- 
>> * Martin C. Stoufer              *
>> * DST/DIDC/ITG                   *
>> * Lawrence Berkeley National Lab *
>> * MS 50B-2239 510-486-8662       *
>>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list