averylongloginname has asked for the wisdom of the Perl Monks concerning the following question:

Question: I am running a website consisting of perl/cgi using IIS 5.0 on a Windows 2000 server. Does anyone know of a nifty error log (ala Apache's error_log) that will give a meaningful message when a page breaks? The event log does not show much of anything in the way of cgi errors.
Your comments are most appreciated.
thanks in advance

Replies are listed 'Best First'.
Re: IIS CGI ErrorLog
by webengr (Pilgrim) on Nov 10, 2001 at 05:31 UTC
    Try putting this,
    use CGI::Carp qw(fatalsToBrowser);
    in your scripts. This will send the perl error messages to the browser, saving you from having to burrow through the server logs only to find something completely non-helpful.

    PCS

    UPDATE:

    Use this only for debugging purposes. Turn it off (comment out) when you no longer need it.

Re: IIS CGI ErrorLog
by rchiav (Deacon) on Nov 10, 2001 at 04:49 UTC
    Logs should be stored in WINNT\system32\LogFiles\W3SVC1

    Hope this helps..
    Rich

Re: IIS CGI ErrorLog
by growlf (Pilgrim) on Nov 10, 2001 at 17:00 UTC
    Try using this:
    use CGI::Carp qw/fatalsToBrowser/; sub cgierr{ my ($error, $nolog) = @_; if ( $config{'debug'}==-1 ){ #### TBD: generic error report goes here # return 1; exit; } print $in->header(); #Begin detailed error and debug reporting if ($config{'debug'}) { print "<PRE>\n\nDEBUG\n======================================= +===\n"; } else { print "<PRE>\n\nCGI ERROR\n=================================== +=======\n"; } $error and print "Error Message : $error\n"; $0 and print "Script Location : $0\n"; $] and print "Perl Version : $]\n"; $random_variable_I_want_to_see and print "random variable I want +to see : $random_variable_I_want_to_see\n"; print "\n\nInput Parameters\n------------------------------------- +------\n"; foreach $key (sort $in->param) { my $space = " " x (20 - length($key)); print "$key$space: " . $in->param($key) . "\n"; } print "\nCookies\n-------------------------------------------\n"; print "\n$config{'userpass_cookie_name'} : " . $in->cookie($config +{'userpass_cookie_name'}); print "\n$config{'userid_cookie_name'} : " . $in->cookie($config{' +userid_cookie_name'}); print "\n$config{'back_do_cookie_name'} : " . $in->cookie($confi +g{'back_do_cookie_name'}); print "\nEnvironment Variables\n---------------------------------- +---------\n"; foreach $env (sort keys %ENV) { my $space = " " x (20 - length($env)); print "$env$space: $ENV{$env}\n"; } print "\nStack Trace \n------------------------------------------- +\n"; my $i = 0; while (my ($file, $line, $sub) = (caller($i++))[1,2,3]) { print qq!($sub) called from ($file) line ($line)<BR>\n!; } print "\n</PRE>"; &log_action ("CGI ERROR: $error") if (!$nolog and $config{'logfile +'}); exit; }
    ..and then use it to target suspected error locations, like this:
    <..lines of code..> &cgierr("fatal undef error: $@", 1);
    Also, the visual debugger that comes with Activestates dev kit works well in this instance, but you can also (specuially if you are using CGI) use the debug option when you invoke the script manually and trace it through on the commandline, but that is a bit messy looking the first couple times you do it.

    *G*
Re: IIS CGI ErrorLog
by giulienk (Curate) on Nov 10, 2001 at 13:24 UTC
    If you're using Activestate you should give a look in the C:\Perl\bin (or wherever you installed Activestate) directory for *.log: the error log should be there. I don't have my W2K box here so that's all i remember, sorry.