Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

How can I Disable script.error_log ?

by nickcave25 (Acolyte)
on Feb 18, 2002 at 21:30 UTC ( #146253=perlquestion: print w/replies, xml ) Need Help??

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

After making the transition to a brand new server running FreeBSD 4.4-RELEASE (VKERN) and Perl 5.6.0 (from an earlier FreeBSD/Peerl setup) my scripts run fine, but are causing www/logs/script.error_log to fill up very rapidly -- hence maxing out my disk quota (and causing me related headaches.)

Aside from deleting this file every day and/or actually fixing the subtle bugs in my scripts/programs that are causing the cascade of error messages (heheh)... What can I do to temporarily disable script.error_log from being written to?

I blew away all u/g/o file permissions but it still is getting appended to anyway. Is the -w switch on my #!/usr/bin/perl5 line causing this logging, or would it occur anyway, even without that declared? (I would prefer not to have to edit every single -w out of every script if possible). Please help! :)

Replies are listed 'Best First'.
Re: How can I Disable script.error_log ?
by Malach (Scribe) on Feb 18, 2002 at 21:46 UTC

    -w is there for a reason... to generate warnings about possible problems.

    If you don't care about the warnings, then remove it.

    If you do care about the warnings, then fix the script.

    Personally, I "use warnings;" and "use diagnostics;" during development. I'm of the opinion that once the scripts are completed, these will produce no output, so there's no harm in leaving them in place (in case something occurs that I haven't considered). Then, I'll get my warnings and diagnostics, and should be able to pick up the error faster. In once instance, I couldn't figure out how to avoid the warning before putting the script in production, so I commented out use warnings; (which I later went back and fixed).

    If you have control over the apache config you should be able to alter the logging... but I'd guess you're on a shared hosting service of some sort, so that's probably not an option.

    So, this baby seal walks into a club.....

"-w" is for warnings
by Kozz (Friar) on Feb 18, 2002 at 21:47 UTC
    I don't know that you would want to permanently disable those errors from being logged, but what you might do is this:
    • "use strict" everywhere
    • remove the "-w" flag, which will suppress some minor warnings
    Keep in mind, however, that you should only remove the -w flag if this is a script in which you are confident is working without problems and is in a production environment... typically I run my scripts with -w while debugging, and afterwards will remove the "-w" flag, because it can spew LOTS of errors to your logs, depending on the contents of the script.

    Or perhaps the lazy way would be to truncate the file intermittently with a cronjob.
    */30 * * * * cat /dev/null > /www/logs/script.error_log
    would truncate the file to zero-length every 30 minutes.
Re: How can I Disable script.error_log ?
by joealba (Hermit) on Feb 19, 2002 at 06:00 UTC
    For my CGI scripts, I like to redirect STDERR to a file. I use File::Basename to extract the script filename, open up the error log, and call it a day. You may want to either truncate the error log on each run, or truncate it when it reaches a certain size.

    Sure, there are race conditions. Sure, it'd be much better to run an error logging server. But if your script is stable enough for production and you just don't have the time to track down some verbose, non-critical errors, this method will keep your logs in check.

    But, that's a quick fix. Malach is right. A well-written script shouldn't give you that many errors. Your best bet for long term is to fix your script so it doesn't generate the warnings under -w.
      My preferred solution, while not used for this though it could be, is to have Apache use a perl-script as a logging process. In the script I can do any kind of segregation, ignoring, etc. I want to for any entries.

      If you really want to look at some moldy code here it is, flog. I don't need a code review though, 'm-k? Just glancing at it makes me cringe. But believe it or not I've been using it continuously since I wrote it oh so long ago. I've been meaning to get around to touching it up a bit, maybe someday...

      perl -pe "s/\b;([st])/'\1/mg"

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2022-05-24 08:03 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (82 votes). Check out past polls.