in reply to How to create an error log file?

This is what I use:

BEGIN { require 5.004; use CGI::Carp qw(fatalsToBrowser carpout); my $logfile = 'path/to/logfile'; open LOG, ">>$logfile" or die "Couldn't append to $logfile: $!\n"; carpout(\*LOG); };
This appends to the logfile all the output sent to STDERR, both during compile-time and during run-time. E.g., if I have the line
warn "Logging...\n";
in my code, this will send the following to the logfile:
[Thu Apr 7 05:39:57 2005] testcgi: Logging...

the lowliest monk

Replies are listed 'Best First'.
Re^2: How to create an error log file?
by tsam (Novice) on Apr 07, 2005 at 10:18 UTC
    Hi Pustular, The code works nicely....thanx a lot:)