[mod_python] problems with logging

Graham Dumpleton graham.dumpleton at gmail.com
Sat Aug 16 08:31:25 EDT 2008


Please use reply-all and keep discussion on list.

If it doesn't work, then possibly because I assumed you were talking
about output appearing in Apache error log. Reading code you are
trying to have logging module send it somewhere else. Thus, if you are
complaining that output not appearing in your separate log file, then
can't really help.

Only further comment I can make is that you should not be initialising
logging module in the context of a request handler. You would want to
do it at global scope and preferably in a Python module which isn't
possibly being reloaded causing it to be configured multiple times in
lifetime of process. Also not sure how thread safe configuring logging
module is, which would be an issue when doing it in context of request
handler.

Graham

2008/8/16 Camilo Telles <camilot at terra.com.br>:
> Dear Graham,
>
> It didn't work.
> Any ideas?
>
> Regards,
>
>
> Camilo
>
>> -----Original Message-----
>> From: Graham Dumpleton [mailto:graham.dumpleton at gmail.com]
>> Sent: sábado, 16 de agosto de 2008 09:10
>> To: Camilo Telles
>> Cc: mod_python
>> Subject: Re: [mod_python] problems with logging
>>
>> 2008/8/16 Camilo Telles <camilot at terra.com.br>:
>> > Graham,
>> >
>> > How do I flush it? How I get access to the FileHandler from the logging
>> object?
>> > I prefer to use the logging module, so I can split the content to be
> logged
>> between two files.
>>
>> Use:
>>
>>   import sys
>>   sys.stderr.flush()
>>
>> It is a standard Python file like object.
>>
>> Graham
>>
>> > ---------- Cabeçalho original -----------
>> >
>> > De: "Graham Dumpleton" graham.dumpleton at gmail.com
>> > Para: "Camilo Telles" camilot at terra.com.br
>> > Cópia: "mod_python" mod_python at modpython.org
>> > Data: Sat, 16 Aug 2008 21:22:31 +1000
>> > Assunto: Re: [mod_python] problems with logging
>> >
>> >> The sys.stderr stream in mod_python is buffered, you need to flush it.
>> >> You are better of implementing a logging module handler which logs
>> >> using apache.log_error().
>> >>
>> >> Graham
>> >>
>> >> 2008/8/16 Camilo Telles <camilot at terra.com.br>:
>> >> > Sirs,
>> >> >
>> >> > I have an annoying problem happening with mod_python and logging.
>> >> > Here is the code:
>> >> > ===========================================
>> >> > import logging
>> >> > from mod_python import util
>> >> >
>> >> > def index(req, email):
>> >> >        logging.basicConfig(level=logging.DEBUG,
>> >> >                    format='%(asctime)s;%(message)s',
>> >> >                    filename='log_email.txt',
>> >> >                    filemode='a')
>> >> >        logging.info(email)
>> >> >        logging.shutdown()
>> >> >
>> >> >        util.redirect(req, 'http://dummy/download.html')
>> >> > ======================================
>> >> >
>> >> > What happens: sometimes the logs occurs, sometimes it not. It´s
>> completely random.
>> >> >
>> >> > I´m using:
>> >> >
>> >> > Apache/2.2.8 (Ubuntu)
>> >> > mod_python/3.3.1
>> >> > Python/2.5.2
>> >> >
>> >> > Any clue? I need to do some kind of flush? If yes, how?
>> >> >
>> >> > Thanks in advance.
>> >> >
>> >> > Camilo
>> >> >
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > Mod_python mailing list
>> >> > Mod_python at modpython.org
>> >> > http://mailman.modpython.org/mailman/listinfo/mod_python
>> >> >
>> >>
>> >> Esta mensagem foi verificada pelo E-mail Protegido Terra.
>> >> Atualizado em 16/08/2008
>> >>
>> >>
>> >
>> >
>> > _______________________________________________
>> > Mod_python mailing list
>> > Mod_python at modpython.org
>> > http://mailman.modpython.org/mailman/listinfo/mod_python
>> >
>>
>> Esta mensagem foi verificada pelo E-mail Protegido Terra.
>> Atualizado em 15/08/2008
>
>
>



More information about the Mod_python mailing list