Re: [modwsgi] printf() and mod_wsgi

30 views
Skip to first unread message

Graham Dumpleton

unread,
Oct 2, 2012, 2:17:40 AM10/2/12
to mod...@googlegroups.com
On 23 September 2012 21:27, Linux Omicron <linux....@gmail.com> wrote:
> Hello Everyone,
>
> I am developing a web application using pylons pyramid. I am not using
> default web server waitress but relying on mod_wsgi.
> My pyramid application internally uses a c library. In the c library, some
> places,printf() statement is used for debug logs.
> When I run my pyramid application under mode_wsgi, I observed that debug
> information was being logged in application log file for python print
> statements but none of the printf() were logged.
> Don't print and printf() have same function to print on stdout?
> How do I enable logging using printf() statement?

The issue in this case is going to be how Apache attaches C
stdout/stderr to the Apache error log. The way it is done means it is
effectively buffered. This means that if there is no explicit fflush()
done in the C code to force writing out the messages to the Apache
error log, they will only get flushed when the buffer fills up, or if
you are lucky when the process exits and stdout/stderr are
automatically flushed on closure.

Also be aware that being C level stdio/stderr I/O operations, when the
messages appear in the Apache error log they will not be prefixed with
any timestamp information.

Graham

Linux Omicron

unread,
Dec 4, 2012, 1:46:28 AM12/4/12
to mod...@googlegroups.com
Thanks for reply Graham.
I did try with fflush() in the c library code but no change in output. The log file shows only python print statement but c printf() have been discarded.

Thanks,
Linux Omicron.

Graham Dumpleton

unread,
Dec 5, 2012, 8:01:15 PM12/5/12
to modwsgi
Which log are you looking in. Use of printf() at C level would only go to main Apache error log and never to a virtual host error log.

Graham


--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To view this discussion on the web visit https://groups.google.com/d/msg/modwsgi/-/Z9LGyalT0EwJ.

To post to this group, send email to mod...@googlegroups.com.
To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.

Reply all
Reply to author
Forward
0 new messages