Re: save a log
Aron Szabo <aron-Iv/[email protected]> Thu, 12 Aug 2010 11:20:35 +0200
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
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-xGejAJT2w6xVgU18Zptdi0EOCMrvLtNR@public.gmane.org
> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers
_______________________________________________
FastCGI-developers mailing list
FastCGI-developers-xGejAJT2w6xVgU18Zptdi0EOCMrvLtNR@public.gmane.org
http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers
aron.vcf
(text/x-vcard, 154 B)
begin:vcard fn:Aron Szabo n:Szabo;Aron email;internet:aron-Iv/[email protected] tel;home:+3652999342 tel;cell:+36703271722 version:2.1 end:vcard