httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <Owen.Bo...@swx.com>
Subject RE: [users@httpd] stderr not working with C cgi-bins
Date Tue, 02 Dec 2003 08:33:07 GMT
> -----Original Message-----
> From: Janne.Mattila@keypartners.fi 
> 
> Thank you sir, you are a godsent :) Turns out that when 
> ScriptLog is set,
> stderr is logged neither to error_log nor script_log. How 
> strange. Now I'm
> left wondering how to enable ScriptLog without losing std_err.

My understanding is that a properly configured script_log will trap STDERR from CGI programs.
Obviously, STDOUT is not trapped - this is what is fed back to the client who requested the
CGI.
 
> I do not think the problem is file permissions - I have 
> changed ownership
> of script_log, allowed access to it for everybody, and apache 
> seems to be
> able to write to it just fine when I mistype the cgi-bin name:
> 
> %% [Mon Dec  1 15:23:47 2003] GET 
> /cgi-bin/hellowaorld.cgi?asdf HTTP/1.1
> %% 404 /home/somedirectory/public_html/cgi-bin/hellowaorld.cgi
> %error
> script not found or unable to stat
> 
> Besides that error message, I get nothing in the script_log.


Now I'm confused... The error you quote above is a 404 - it should appear in error_log, even
if you have script_logging enabled. Are you *sure* you got it in the script_log?

The point about ownership is that the user defined by the "User" directive (ie the apache
user) must have *write* privilege on the script_log. This is unlike other logfiles which are
normally only written to by the parent apache process which is owned by root. This is so that
individual apache daemons (which run as apache user) can have direct write access to the script_log.

If you want to test the script_log with a system-generated STDERR message, put a run-time
error in the program, eg:

int x = 0;
float y = 5/x;

and see where the divide-by-zero error goes.






> 
> - - -
> Janne Mattila
> 
> 
> 
> |---------+---------------------------->
> |         |           "Boyle Owen"     |
> |         |           <Owen.Boyle@swx.c|
> |         |           om>              |
> |         |                            |
> |         |           01.12.2003 15:18 |
> |         |           Please respond to|
> |         |           users            |
> |         |                            |
> |---------+---------------------------->
>   
> >-------------------------------------------------------------
> -------------------------------------------------|
>   |                                                           
>                                                    |
>   |       To:       <users@httpd.apache.org>                  
>                                                    |
>   |       cc:       (bcc: Janne Mattila/FI/TJG)               
>                                                    |
>   |       Subject:  RE: [users@httpd] stderr not working with 
> C cgi-bins                                         |
>   
> >-------------------------------------------------------------
> -------------------------------------------------|
> 
> 
> 
> 
> > -----Original Message-----
> > From: Janne.Mattila@keypartners.fi
> > [mailto:Janne.Mattila@keypartners.fi]
> > Sent: Montag, 1. Dezember 2003 13:06
> > To: users@httpd.apache.org
> > Subject: [users@httpd] stderr not working with C cgi-bins
> >
> >
> > Hi,
> >
> > I am running apache 1.3 on Solaris 8 and developing cgi-bins
> > with C. For
> > all I know, everything works fine except that I am unable to
> > get writes to
> > stderr to appear in error_log. I have a simple test cgi-bin program:
> 
> Not sure STDERR will go to the error_log if you also have a 
> script_log.
> Is there nothing in the script_log? If not, who owns 
> script_log? It must
> be owned by apache User (ie not by root) or it won't work.
> 
> Rgds,
> Owen Boyle
> Disclaimer: Any disclaimer attached to this message may be ignored.
> 
> >
> > - - - - - - 8< - - - - - -
> >
> > #include <stdio.h>
> >
> > int main() {
> >    printf("Content-Type: text/html\r\n\r\n");
> >    printf("<html> <head>\n");
> >    printf("<title>Hello, World !</title>\n");
> >    printf("</head>\n");
> >    printf("<body>\n");
> >    printf("<h1>Hello, World!</h1>\n");
> >    fprintf(stderr, "debug message to stderr\n\n");
> >    fprintf(stdout, "debug message to stdout\n\n");
> > }
> >
> > - - - - - - 8< - - - - - -
> >
> > Accessing cgi-bin/helloworld.cgi produces the logical output,
> > including the
> > debug messages printed to stdout. Nothing goes to error_log - I am
> > expecting to get the debug messages there. Running the
> > compiled cgi-bin
> > from shell displays both stderr and stout writes.
> >
> > On httpd.conf I have settings:
> >
> > - - - - - - 8< - - - - - -
> >
> > ErrorLog /etc/apache/logs/error_log
> > ScriptLog /etc/apache/logs/script_log
> > LogLevel debug
> > CustomLog logs/access_log combined
> >
> > <VirtualHost _default_:443>
> > ErrorLog /etc/apache/logs/error_log
> > TransferLog /etc/apache/logs/access_log
> > ...
> > CustomLog logs/ssl_request_log \
> >           "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
> >
> > </VirtualHost>
> >
> > - - - - - - 8< - - - - - -
> >
> > As far as I know, start up scripts do not redirect stderr anywhere.
> >
> > error_log works at least somehow, when I try to access
> > non-existing cgi-bin
> > I get logical error messages to error_log and script_log.
> >
> > Any ideas what could be wrong?
> >
> > - - -
> > Janne Mattila
> >
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP
> > Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
> Diese E-mail ist eine private und persönliche Kommunikation. Sie hat
> keinen Bezug zur Börsen- bzw. Geschäftstätigkeit der SWX Gruppe. This
> e-mail is of a private and personal nature. It is not related to the
> exchange or business activities of the SWX Group. Le présent 
> e-mail est
> un message privé et personnel, sans rapport avec l'activité 
> boursière du
> Groupe SWX.
> 
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any mistransmission.
> If you receive this message in error, please notify the 
> sender urgently
> and then immediately delete the message and any copies of it from your
> system. Please also immediately destroy any hardcopies of the message.
> You must not, directly or indirectly, use, disclose, 
> distribute, print,
> or copy any part of this message if you are not the intended 
> recipient.
> The sender's company reserves the right to monitor all e-mail
> communications through their networks. Any views expressed in this
> message are those of the individual sender, except where the message
> states otherwise and the sender is authorised to state them to be the
> views of the sender's company.
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message