in reply to Capturing Error message in a log file.

First, have you tried using the "%attrib" part of the DBI "connect()" call? It can be used to set parameters like "PrintError" and "RaiseError", which might help to control the reporting behavior in the way that you want.

Second, if you have access to a bash or bourne shell, you could just redirect STDERR to a file at the command line, like this:

your_script [options and args] 2> errlog
(There is a Windows port of bash, if you happen to be on a Windows system.)

Finally, if neither of the above points will work for you, try this at the beginning of your script:

open( STDERR, ">>$debug_output" ) or die "Can't write errlog: $!\n";
That way, you don't need any special functions or special DBI connect args -- everything that Perl would normally print to STDERR will be stored in the file whose name is provided in "$debug_output". (The original STDERR handle will be closed, so no error messages will go to the console.)

Replies are listed 'Best First'.
Re: Re: Capturing Error message in a log file.
by pfaut (Priest) on Jan 03, 2003 at 13:25 UTC
    Second, if you have access to a bash or bourne shell, you could just redirect STDERR to a file at the command line, like this:
    your_script options and args 2> errlog

    Windows 2000 command shell allows this type of redirection, too. Our build system at work used it until I rewrote the whole thing in perl.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';