O wise ones,

Humbled, as always, at your presence, I seek your wisdom on a problem
that we are having, trying to maintain our web application on Windows
systems. The following is a description of the issue that my colleague
has put together.

Abstract
========================================
Enabling mod_perl in my Win32 environment causes Perl warnings to
disappear. Warnings from CORE and those from explicit "warn" api calls
don't appear in error.log, although "die" messages do appear. There is
no problem when operating in plain CGI mode. There is no problem with
the application running on Linux, mod_perl or otherwise.


Platform details
========================================
   * Windows XP Professional SP2
   * Apache 2.0.54
   * perl v5.8.6 built for MSWin32-x86-multi-thread


httpd.conf contents
========================================
...
ThreadsPerChild 100
MaxRequestsPerChild 0
...
ErrorLog logs/error.log
...
LogLevel warn
...


Some tests
========================================
When warn is aliased to Apache2::ServerRec::warn, like

*CORE::GLOBAL::warn = \&Apache2::ServerRec::warn;


messages are recorded in error.log. However, in order to have all
STDERR messages (like, perl warnings etc.) recorded in error.log, i've
tried

local $SIG{__WARN__} = \&Apache2::ServerRec::warn;


But it doesn't work, maybe since alarms are not reliable in Win32.

Apache's loglevel is "warn", (i verified that by inspecting loglevel
at runtime by: $loglevel = $s->loglevel();)

Please have a look at the code segment below, when warn is redirected to mywarn

 use Apache2::Const -compile => qw(:log);
 use APR::Const     -compile => qw(ENOTIME SUCCESS);

 *CORE::GLOBAL::warn = \&mywarn;

 sub mywarn
 {
  my @msg = @_;

  my $s = Apache2::ServerUtil->server;
  $s->log_serror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_WARNING,
          APR::Const::SUCCESS, @msg);
  $s->log_serror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_ERR,
          APR::Const::SUCCESS, @msg);
 }

Each "warn" message appears twice as expected: first as a [warn], next
as an [error]. So I shouldn't have a problem with LogLevel in
httpd.conf, since warnings appear without a problem.

How can I enable STDERR messages to appear in error.log in a Win32 environment?

I would prefer not to introduce such hacks to warn, carp etc either.


-- Ali Isik
I just posted this message on perlmonks as well:
http://perlmonks.org/?node_id=612175

Reply via email to