save a log
Doru Georgescu <headset001-/[email protected]> Thu, 12 Aug 2010 01:09:35 -0700 (PDT)
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
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