I set autoflush on so the last msg before it crashes actually reaches the disk file instead of being buffered in mem and possibly not reaching the file.sub create_logfile { my ( $logfile, # final logfile name $filename, # filename sans extension $filext, # filename extension $filedir # dir for logfile ); # Get filename components ($filename, $filedir, $filext) = fileparse($0, '\..*'); # Create filename $logfile = "${filedir}log/$filename.log"; # Redirect STDOUT & STDERR to named logfile open( STDOUT, ">$logfile") or die "\nUnable to open logfile $logfile: $!\n"; open( STDERR, ">>&STDOUT"); # Set autoflush on select (STDERR); $| = 1; select (STDOUT); $| = 1; }
Cheers
Chris
In reply to Re: how to send both STDOUT and STERR to the same file
by chrism01
in thread how to send both STDOUT and STERR to the same file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |