[FASTCGI] save a log

Aron Szabo aron at aron.ws
Thu Aug 12 05:20:35 EDT 2010


  Hi Doru!

You should be able to write to the disk normally.

The data does not get flushed to the disk.
Try flushing the data to the disk with fflush(mylog);, or closing the 
file after the program ends.

Yours sincerely,
Aron Szabo
Pointless Software
pointless.hu

On 08/12/2010 10:09 AM, Doru Georgescu wrote:
> 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
>
>
>
>
>
> _______________________________________________
> FastCGI-developers mailing list
> FastCGI-developers at mailman.fastcgi.com
> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers

-------------- next part --------------
A non-text attachment was scrubbed...
Name: aron.vcf
Type: text/x-vcard
Size: 133 bytes
Desc: not available
URL: <http://mailman.pins.net/mailman/private.cgi/fastcgi-developers/attachments/20100812/feb00c6c/attachment.vcf>


More information about the FastCGI-developers mailing list