Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
ccgi and weblogs, where does STDERR go?
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- ccgi and weblogs, where does STDERR go?
ccgi and weblogs, where does STDERR go?
15-04-2008 8:53 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've been trying out some perl scripts and I know that they'll have written some trace info to STDERR. Supposedly anything a script writes to STDERR is supposed to get logged but this doesn't seem to be the case.
should I see warnings in the logfile or do Plusnet direct them to /dev/null? I can quite understand the latter, and can work around it by diverting the messages e.g. with CGI::Carp's fatalsToBrowser option but I'd like to know?
edit: Oops, I meant STDERR not STDOUT
should I see warnings in the logfile or do Plusnet direct them to /dev/null? I can quite understand the latter, and can work around it by diverting the messages e.g. with CGI::Carp's fatalsToBrowser option but I'd like to know?
edit: Oops, I meant STDERR not STDOUT
Message 1 of 6
(1,516 Views)
5 REPLIES 5
Re: ccgi and weblogs, where does stdout go?
15-04-2008 9:29 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
stdout and strerr sends output direct to the console (i.e. your telnet sesson) when you run them from the command line. When run from a browser they are probably ignored and not logged anywhere in a multi-host webserver environment.
You best bet is to find some way to redirect the output to a file.
You best bet is to find some way to redirect the output to a file.
Message 2 of 6
(465 Views)
Re: ccgi and weblogs, where does stdout go?
16-04-2008 9:24 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
When running a script through the browser, STDOUT is sent to the browser. In perl for example, [tt]print 'Test'[/tt] is sent to STDOUT and will display in the browser.
Message 3 of 6
(465 Views)
Re: ccgi and weblogs, where does stdout go?
16-04-2008 4:29 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've got it mixed up again, I meant STDERR. I've learned the hard way where STDOUT goes as anything at all written before the HTTP header breaks it totally.
As far as I know "warn","carp","die" and "croak" (and "cluck" and "confess") all send their output to STDERR by default. Adding CGI::Carp makes it format the message nicely with a date and time in front on the assumption that Apache will capture STDERR into the logfile.
Plan B as Peter points out is to redirect the output to a seperate logfile on the cgi server. Easier said than done when the example given by cpan throws an error when run with "use strict" selected.
Oh well I've now got it to work and made the script carry on quietly without logging if the logfile can't be opened instead of throwing a 500 error.
As far as I know "warn","carp","die" and "croak" (and "cluck" and "confess") all send their output to STDERR by default. Adding CGI::Carp makes it format the message nicely with a date and time in front on the assumption that Apache will capture STDERR into the logfile.
Plan B as Peter points out is to redirect the output to a seperate logfile on the cgi server. Easier said than done when the example given by cpan throws an error when run with "use strict" selected.
Oh well I've now got it to work and made the script carry on quietly without logging if the logfile can't be opened instead of throwing a 500 error.
Message 4 of 6
(465 Views)
Re: ccgi and weblogs, where does STDERR go?
16-04-2008 4:38 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
oliverb: http://www.issociate.de/board/post/261491/Redirecting_STDERR.html
Kelly Dorset
Ex-Broadband Service Manager
Ex-Broadband Service Manager
Message 5 of 6
(465 Views)
Re: ccgi and weblogs, where does STDERR go?
16-04-2008 7:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Thankfully with CGI::Carp there's the "carpout" function, so I can dodge having to save and restore the filehandle myself.
This is based on the example in the docs except that I've replaced the "do or die" file open with "open and do stuff" so it doesn't bomb if the file can't be opened, also the star in front of LOG prevents a bareword error.
BEGIN
{
use CGI::Carp qw(carpout);
open(LOG, ">>log/mycgi-log.txt") and
carpout(*LOG);
}
This is based on the example in the docs except that I've replaced the "do or die" file open with "open and do stuff" so it doesn't bomb if the file can't be opened, also the star in front of LOG prevents a bareword error.
Message 6 of 6
(465 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- ccgi and weblogs, where does STDERR go?