[FASTCGI] save a log

Doru Georgescu headset001 at yahoo.com
Thu Aug 12 04:09:35 EDT 2010


Thank you all for your answers, I did not know about the syslog functions. 

However, I want to log all my application's activity, and for the beginning I would like to put it in a separate file. 

"1. AFAIK, you should be able to write to disk just like from any other process."

This program does not write to log/mylog: 

   #include <stdlib.h>
   #include "fcgi_stdio.h"

    int main(void)
    {
        FILE *mylog;
        mylog=fopen("log/mylog", "a");

        int count = 0;
        while(FCGI_Accept() >= 0){
            printf("Content-type: text/html\r\n"
                   "\r\n"
                   "<title>FastCGI Hello!</title>"
                   "<h1>FastCGI Hello!</h1>"
                   "Request number %d running on host <i>%s</i><br />\n"
                   "Get parameters: %s<br />\n"
                   "mylog= %p<br />\n",
                    ++count, getenv("SERVER_NAME"), getenv("QUERY_STRING"), mylog);
//        FCGI_Finish();
        fprintf(mylog, "I am writing in mylog!\n");}

    }

It creates the file, the permissions are right, but it does not write anything. 

If you search "FCGI_ToFile" on this page: 
http://www.fastcgi.com/devkit/doc/fcgi-devel-kit.htm#S3.1, 
you will see that fprinf(FCGI_ToFile(mylog), "I am writing..."); is supposed to work, but in reality it doesn't, because FCGI_ToFile is not defined in fcgi_stdio.h. 

So, how can you write to the disk from a fcgi application? 

Thanks again, 
Doru 




      


More information about the FastCGI-developers mailing list