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

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.


In reply to Warnings awol in Win32 mod_perl. by fenLisesi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.