[mod_python] problems with logging

Graham Dumpleton graham.dumpleton at gmail.com
Sat Aug 16 07:22:31 EDT 2008


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
>



More information about the Mod_python mailing list