bwelch has asked for the wisdom of the Perl Monks concerning the following question:
For a while now, we have been testing a script that runs several cluster applications. We found the error output went only to the screen of shell where it was run. making it difficult for multiple to work together to locate the problem.
Directing STDERR to a file helped, but it was hard to figure out where in the script the error occurred. I found this code works best by redirecting STDOUT and STDERR both to the log file. It seems to work well, but we've only started using it. Do you see any problems or ways to improve this?
use strict; # Set up main log open LOG, ">$logfile" || die "$0: Can't open log file!"; open ( STDERR, ">>$logfile" ); open ( STDOUT, ">>$logfile" ); select( LOG ); $| = 1; # Turn on buffer autoflush for log output select( STDOUT );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Redirecting logging and STDERR to a single file
by Limbic~Region (Chancellor) on Mar 04, 2005 at 17:40 UTC | |
Re: Redirecting logging and STDERR to a single file
by moot (Chaplain) on Mar 04, 2005 at 17:50 UTC | |
Re: Redirecting logging and STDERR to a single file
by johnnywang (Priest) on Mar 04, 2005 at 23:41 UTC | |
Re: Redirecting logging and STDERR to a single file
by brian_d_foy (Abbot) on Mar 04, 2005 at 21:37 UTC |
Back to
Seekers of Perl Wisdom