Wojciech Pietron wrote:
...
use CGI qw(header param url_param url);
use CGI::Carp qw(fatalsToBrowser croak carp carpout);

my ($pwd, $errorlog, $fh);

BEGIN {
   $pwd = qx|/bin/pwd|;
   chop $pwd;
   $errorlog = "$pwd/myerror.log";
   $fh = new FileHandle ">> $errorlog";
   carpout($fh);
}

# functions printing to STDERR ...
======================================================


If I use CGI instead of mod_perl, it is OK. I have all my STDERR messages at
myerror.log. But when I put my script in mod_perl environment then I have some
of the messages in myerror.log and some in standard Apache error_log file. If
I run my script a few times, I can see that the message appears randomly either in myerror.log or in error_log file.


I am not able to determine when messages are going to myerror.log and when they
are going to error_log. Is it a feature of mod_perl?



In mod_perl, you should be aware that BEGIN {} blocks only get executed the first time a script is compiled, so is not a reliable place to execute code that you want executed once per script. If you reall want the code execute each request, put it into a subroutine, and call that routine each time.

Regards,

Josh

________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checker                 http://www.nodeworks.com



--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to