Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How do I...Redirect error.log data to a file of my chosing

by S_Shrum (Pilgrim)
on Jun 01, 2002 at 06:31 UTC ( [id://170886]=perlquestion: print w/replies, xml ) Need Help??

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

The admins at 1dollarhosting.com blow...

After screwing up the server that my site had happily been running my scripts on for 3 years, they tell me (after I sent them a nasty "What da heck?" email) that I can move my content to a newer, faster machine to avoid these sort of problems in the future (that sounds like a empty promise so I will treat it as such). I agree, b/u my site and give them the green light.

After the move, I u/l'ed my site to find out that my scripts no longer work. No problem, right? I can just view the error.log to see what the problem is to fix it. Only problem is that I have no /log folder access any more (they've been working on fixing it for the last MONTH!).

Anyways, with that out of my system, is there a way that I can, for the time being or as a permenant workaround, redirect the data that gets sent to the error.log file to a file of my chosing? I need the error.log information to debug issues as the scripts run beautifully on my WinXP/Apache/ASPerl setup but not on their FreeBSD/Apache/ASPerl setup

P.S.: No, it's not a shebang issue (I only wish it was that simple).

TIA

======================
Sean Shrum
http://www.shrum.net

  • Comment on How do I...Redirect error.log data to a file of my chosing

Replies are listed 'Best First'.
Re: How do I...Redirect error.log data to a file of my chosing
by Beatnik (Parson) on Jun 01, 2002 at 07:31 UTC
    Try CGI::Carp?
    BEGIN { use CGI::Carp qw(carpout); open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or die("Unable to open mycgi-log: $!\n"); carpout(LOG); #Correct way, according to tchrist, is carpo +ut(\*LOG); }
    Or you can just use fatalsToBrowser :)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
        Your choice ofcourse :) the CGI::Carp POD mentioned the above example :)

        Greetz
        Beatnik
        ... Quidquid perl dictum sit, altum viditur.

        This works great...

        I'm finding that having to run my script, having it fail, going to the log file, openning it, scrolling to the bottom is just too time consuming. How can I carpout to the browser for faster debugging?

        ======================
        Sean Shrum
        http://www.shrum.net

      If that open failed, how would S_Shrum be any more enlightened? :)

      Perhaps something more along the lines of...

      open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or do { my $error = "Unable to open mycgi-log: $!\n"; print "Content-Type: text/plain\n\n", $error; # to the screen die $error; # & the logs };

      ...until you're sure that isn't going to kill the script, too (keeping in mind that you may reveal your log path to any visitors).

          --k.


Re: How do I...Redirect error.log data to a file of my chosing
by vagnerr (Prior) on Jun 02, 2002 at 13:31 UTC
    Just a thaught but using Carp and so forth might not help if the new machine has perl installed in a different place, or not at all. Have you tried a *realy* simple perl script to make sure that perl itself is still working on the new machine?

    ---If it doesn't fit use a bigger hammer

      Perl is functional as I did a simple "hello world" test.

      The problem that I am finding *now* is that the "use lib" I have defined to point to my modules location is invalid. I have tried the following:

      use lib "/lib";
      use lib "/cgi-bin/lib";
      use lib "$ENV{'DOCUMENT_ROOT'}/cgi-bin/lib";
      use lib "/home/httpd/www.shrum.net/cgi-bin/lib";

      ...but none of these work. I have a email into the support guys at 1dollarhosting to get the correct prefix path to use in the "USE LIB".

      Thanx

      ======================
      Sean Shrum
      http://www.shrum.net

        With this much grief, I would have changed providers long before now ...

        That said, you probably want use lib './lib'; if the lib directory is in the same place you keep your CGIs.

        That should even work in a chrooted environment, but if it doesn't I suggest some careful probing of where your scripts think they are and what they can see.

            --k.


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-25 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found