Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Getting error messages from IIS with PerlScript

by krisahoch (Deacon)
on Aug 09, 2005 at 13:47 UTC ( #482210=perlquestion: print w/replies, xml ) Need Help??

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

Monks,

Error message retrieval from IIS using PerlScript is a pain. IIS does not log its errors to a STDERR, only to STDOUT. If you recieve an error in your PerlScript, it only goes the the browser, and is not sent to a log file. There is no time stamp associated with the error either.

I need to capture the IIS error message in a log file. I have tried useing Win32::ASP::AddDeathHooks(...) but that only works if you call the die() function (as opposed to if you write my $quotient = 4/0).

Has anyone out there had experiance trying to capture IIS error messages? Can anyone point me in the right direction?

Thank you,

Kristofer Hoch

Replies are listed 'Best First'.
Re: Getting error messages from IIS with PerlScript
by gellyfish (Monsignor) on Aug 09, 2005 at 13:54 UTC

    you may want to see the CGI::Carp's carpout function.

    /J\

Re: Getting error messages from IIS with PerlScript
by ikegami (Patriarch) on Aug 09, 2005 at 13:53 UTC

    Have you tried $SIG{__WARN__} and $SIG{__DIE__}. They are documented in perlvar.

      ikegami,
      Here is what I have tried already.
      <%@Language=PerlScript%> <% use strict; use Win32::ASP; use vars qw($Response $Request $Server); # Turn on buffering...allows us # to send headers whenever we want. $Response->{Buffer} = 1; # turn OFF page caching. This will hopefully # fix some of IIS's HORRIBLE shortcomings. $Response->{Expires} = 0; $Response->AddHeader('pragma', 'no-cache'); $Response->AddHeader('cache-control','private'); $SIG{__DIE__} = sub { $Response->Write("<h1>Death!</h1>"); }; $SIG{__WARN__} = sub { $Response->Write("<h1>Warning!</h1>"); }; %> <%= my $bad_value = 4/0 %>
      And here is what it begets (in the Browser window only, nothing in logs.
      PerlScript Error error '80004005' (in cleanup) Illegal division by zero /index.asp, line 18

      I am trying to capture that output and throw it to an error log. The problem is that I haven't been about to capture it. If matters weren't bad enough, I have no access to the administration of the host server. I can only access my directory (Global.asa is not an option).

      Thank you,
      Kristofer Hoch

        You said you wanted to log the errors, not send them to the client. I think the handlers are getting called, and you can log the errors from within them.

        If you want to send the error to the client, you'll either need to do some fancy ASP stuff, or use eval BLOCK. For example,

        eval { ... something_that_might_die(); ... }; if ($@) { # It died. # The error message is in $@ ... }

        That won't catch division by zero, but it will catch just about everything else. To catch division by zero, check the denominator before dividing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://482210]
Approved by Nevtlathiel
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-05-22 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?