You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Daniel B. Hemmerich" <da...@webclients.net> on 2005/05/31 14:36:27 UTC

Apache Error Log Format

Hello all...

When a misconfiguration occurs, we receive a new line in the apache 
error logs that is not in the standard error log format (I assume since 
MP is writing to STDERR). Short of changing all of our scripts to 
properly log, is there a quicker method to accomplish the following change:

Change this:

Can't locate /www/path/goes/here//config.pl in @INC (@INC contains: 
/usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
/usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
/usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
at /www/example.com/cgi-bin/example.cgi line 64.

To this:

[Thu May 19 08:47:41 2005] [error] [MODULENAME Can't locate 
/www/path/goes/here//config.pl in @INC (@INC contains: 
/usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
/usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
/usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
at /www/example.com/cgi-bin/example.cgi line 64.

Thanks in advance!

Re: Apache Error Log Format

Posted by Stas Bekman <st...@stason.org>.
Daniel B. Hemmerich wrote:
> Stas Bekman wrote:
> 
>> Who generates this "Can't locate" message? Normal die() messages 
>> should already be prefixed.
> 
> 
> This is occuring during a require, such as:
> 
> require '/www/path/goes/here//config.pl';
 >
> The script itself is poorly written since it should be doing its own -e 
> check prior to requiring it (in my opinion).

Daniel, as we have talked before I remember you're using mp1, but in the 
future please always submit a complete bug report, so we know more about 
your setup. Please see: http://perl.apache.org/bugs/

In mp2 you will get a proper logging on this type of failure. In mp1, you 
could either use this technique:

   eval { require ... };
   if ($@) {
      # handle the exception here
      # $@ contains the error message
   }

or:

   local $SIG{__DIE__} = sub { # handle the exception here,
                               # $_[0] contains the error message }
   require ...;

in your exception handler you can fixup the logging format.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Apache Error Log Format

Posted by "Daniel B. Hemmerich" <da...@webclients.net>.
Stas Bekman wrote:

> Who generates this "Can't locate" message? Normal die() messages should 
> already be prefixed.

This is occuring during a require, such as:

require '/www/path/goes/here//config.pl';

The script itself is poorly written since it should be doing its own -e 
check prior to requiring it (in my opinion).

> If for some reason it's not working (which we should figure out why) you 
> can always override CORE::GLOBAL::die to add the prefix or it can be 
> done via $SIG{__DIE__} override.

Re: Apache Error Log Format

Posted by Stas Bekman <st...@stason.org>.
[guys, please trim the followups to quote only parts you reply to. 
Otherwise the threads are impossible to read later on. Thank you]

Daniel B. Hemmerich wrote:
> Hello all...
> 
> When a misconfiguration occurs, we receive a new line in the apache 
> error logs that is not in the standard error log format (I assume since 
> MP is writing to STDERR). Short of changing all of our scripts to 
> properly log, is there a quicker method to accomplish the following change:
> 
> Change this:
> 
> Can't locate /www/path/goes/here//config.pl in @INC (@INC contains: 
> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
> at /www/example.com/cgi-bin/example.cgi line 64.
> 
> To this:
> 
> [Thu May 19 08:47:41 2005] [error] [MODULENAME Can't locate 
> /www/path/goes/here//config.pl in @INC (@INC contains: 
> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
> at /www/example.com/cgi-bin/example.cgi line 64.
> 
> Thanks in advance!

Who generates this "Can't locate" message? Normal die() messages should 
already be prefixed.

If for some reason it's not working (which we should figure out why) you 
can always override CORE::GLOBAL::die to add the prefix or it can be done 
via $SIG{__DIE__} override.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Apache Error Log Format

Posted by "Daniel B. Hemmerich" <da...@webclients.net>.
That sounds more like the opposite...

I do want Apache to be prefixing each error message with its data...

Unless I misunderstood what that page was saying

Arshavir Grigorian wrote:
> Daniel B. Hemmerich wrote:
> 
>> Thanks for the good idea... it is a direction worth investigating 
>> further. Until someone offers a potentially better solution, I will 
>> play around with this and hopefully in the next few days report back 
>> on my results!
>>
>> Thanks again,
>> Daniel
>>
>> Jonathan Vanasco wrote:
>>
>>>
>>> I really have no idea, but no one has chimed up on this, so I'll try 
>>> to help (and maybe someone here can clear up my misconceptions)
>>>
>>> MP writes to STDERR, BUT things can get weird because of the way 
>>> apache2 handles error messages --
>>>
>>> I could have this wrong, but mp errors and perl errors seem to go to 
>>> the main apache error log ( on my system that's 
>>> /usr/local/apache2/logs/error_log ).
>>>
>>> When i specify a separate errorlog for a vhost, STDERR is directed there
>>>
>>> I  don't know how to accomplish what you want , but I think I can 
>>> help point you in a direction:
>>>
>>> When I saw this post, i remembered how the default OSX apache2/mp had 
>>> a specific compile time option that didn't 'print' to apache -- i 
>>> think one had to call $r->print() instead of print, because of how 
>>> STDOUT was directed.
>>>     The 'fix' was either to recompile apache, or set up a perl 
>>> handler to tie STDOUT to Apache
>>>
>>> I'm found a post about this on google (not sure if its the 'right' 
>>> one, i came across this 2 years ago):
>>>     http://www.macosxhints.com/article.php?story=20031129120521712
>>>         PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless 
>>> tied *STDOUT; }"
>>>
>>> Based on that, i *think* that you could probably write a handler that 
>>> intercepts STDERR, rewrites it to your specifications, and 
>>> ties/redirects it somewhere
>>>
>>> But , two things worry me about this:
>>>   a_ i'm not quite sure of the mechanics of the multiple log files 
>>> that apache can generate, and which one(s) would have what you want 
>>> -- or how to intercept them
>>>   b_ i'm quite sure that there is a better way, that probably uses 
>>> more of the apache configuration powers of mod_perl, and not a crazy 
>>> hack like this
>>>
>>> Again, I dont have much of an idea on this -- but no one else chimed 
>>> up and that tie to STDOUT really popped out in my memories when I 
>>> read this post.
>>>
>>>
>>>
>>> On May 31, 2005, at 8:36 AM, Daniel B. Hemmerich wrote:
>>>
>>>> Hello all...
>>>>
>>>> When a misconfiguration occurs, we receive a new line in the apache 
>>>> error logs that is not in the standard error log format (I assume 
>>>> since MP is writing to STDERR). Short of changing all of our scripts 
>>>> to properly log, is there a quicker method to accomplish the 
>>>> following change:
>>>>
>>>> Change this:
>>>>
>>>> Can't locate /www/path/goes/here//config.pl in @INC (@INC contains: 
>>>> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
>>>> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
>>>> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl 
>>>> .) at /www/example.com/cgi-bin/example.cgi line 64.
>>>>
>>>> To this:
>>>>
>>>> [Thu May 19 08:47:41 2005] [error] [MODULENAME Can't locate 
>>>> /www/path/goes/here//config.pl in @INC (@INC contains: 
>>>> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
>>>> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
>>>> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl 
>>>> .) at /www/example.com/cgi-bin/example.cgi line 64.
>>>>
>>>> Thanks in advance!
>>>
>>>
>>>
>>>
> 
> Maybe it has to do with this:
> 
> http://perl.apache.org/docs/2.0/user/install/install.html#Apache
> 
> -DAP_UNSAFE_ERROR_LOG_UNESCAPED
> 
> 
> 

Re: Apache Error Log Format

Posted by Arshavir Grigorian <ag...@m-cam.com>.
Daniel B. Hemmerich wrote:
> Thanks for the good idea... it is a direction worth investigating 
> further. Until someone offers a potentially better solution, I will play 
> around with this and hopefully in the next few days report back on my 
> results!
> 
> Thanks again,
> Daniel
> 
> Jonathan Vanasco wrote:
> 
>>
>> I really have no idea, but no one has chimed up on this, so I'll try 
>> to help (and maybe someone here can clear up my misconceptions)
>>
>> MP writes to STDERR, BUT things can get weird because of the way 
>> apache2 handles error messages --
>>
>> I could have this wrong, but mp errors and perl errors seem to go to 
>> the main apache error log ( on my system that's 
>> /usr/local/apache2/logs/error_log ).
>>
>> When i specify a separate errorlog for a vhost, STDERR is directed there
>>
>> I  don't know how to accomplish what you want , but I think I can help 
>> point you in a direction:
>>
>> When I saw this post, i remembered how the default OSX apache2/mp had 
>> a specific compile time option that didn't 'print' to apache -- i 
>> think one had to call $r->print() instead of print, because of how 
>> STDOUT was directed.
>>     The 'fix' was either to recompile apache, or set up a perl handler 
>> to tie STDOUT to Apache
>>
>> I'm found a post about this on google (not sure if its the 'right' 
>> one, i came across this 2 years ago):
>>     http://www.macosxhints.com/article.php?story=20031129120521712
>>         PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless 
>> tied *STDOUT; }"
>>
>> Based on that, i *think* that you could probably write a handler that 
>> intercepts STDERR, rewrites it to your specifications, and 
>> ties/redirects it somewhere
>>
>> But , two things worry me about this:
>>   a_ i'm not quite sure of the mechanics of the multiple log files 
>> that apache can generate, and which one(s) would have what you want -- 
>> or how to intercept them
>>   b_ i'm quite sure that there is a better way, that probably uses 
>> more of the apache configuration powers of mod_perl, and not a crazy 
>> hack like this
>>
>> Again, I dont have much of an idea on this -- but no one else chimed 
>> up and that tie to STDOUT really popped out in my memories when I read 
>> this post.
>>
>>
>>
>> On May 31, 2005, at 8:36 AM, Daniel B. Hemmerich wrote:
>>
>>> Hello all...
>>>
>>> When a misconfiguration occurs, we receive a new line in the apache 
>>> error logs that is not in the standard error log format (I assume 
>>> since MP is writing to STDERR). Short of changing all of our scripts 
>>> to properly log, is there a quicker method to accomplish the 
>>> following change:
>>>
>>> Change this:
>>>
>>> Can't locate /www/path/goes/here//config.pl in @INC (@INC contains: 
>>> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
>>> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
>>> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl 
>>> .) at /www/example.com/cgi-bin/example.cgi line 64.
>>>
>>> To this:
>>>
>>> [Thu May 19 08:47:41 2005] [error] [MODULENAME Can't locate 
>>> /www/path/goes/here//config.pl in @INC (@INC contains: 
>>> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
>>> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
>>> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl 
>>> .) at /www/example.com/cgi-bin/example.cgi line 64.
>>>
>>> Thanks in advance!
>>
>>
>>

Maybe it has to do with this:

http://perl.apache.org/docs/2.0/user/install/install.html#Apache

-DAP_UNSAFE_ERROR_LOG_UNESCAPED



-- 
Arshavir Grigorian
Systems Administrator/Engineer

Re: Apache Error Log Format

Posted by "Daniel B. Hemmerich" <da...@webclients.net>.
Thanks for the good idea... it is a direction worth investigating 
further. Until someone offers a potentially better solution, I will play 
around with this and hopefully in the next few days report back on my 
results!

Thanks again,
Daniel

Jonathan Vanasco wrote:
> 
> I really have no idea, but no one has chimed up on this, so I'll try to 
> help (and maybe someone here can clear up my misconceptions)
> 
> MP writes to STDERR, BUT things can get weird because of the way apache2 
> handles error messages --
> 
> I could have this wrong, but mp errors and perl errors seem to go to the 
> main apache error log ( on my system that's 
> /usr/local/apache2/logs/error_log ).
> 
> When i specify a separate errorlog for a vhost, STDERR is directed there
> 
> I  don't know how to accomplish what you want , but I think I can help 
> point you in a direction:
> 
> When I saw this post, i remembered how the default OSX apache2/mp had a 
> specific compile time option that didn't 'print' to apache -- i think 
> one had to call $r->print() instead of print, because of how STDOUT was 
> directed.
>     The 'fix' was either to recompile apache, or set up a perl handler 
> to tie STDOUT to Apache
> 
> I'm found a post about this on google (not sure if its the 'right' one, 
> i came across this 2 years ago):
>     http://www.macosxhints.com/article.php?story=20031129120521712
>         PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless tied 
> *STDOUT; }"
> 
> Based on that, i *think* that you could probably write a handler that 
> intercepts STDERR, rewrites it to your specifications, and 
> ties/redirects it somewhere
> 
> But , two things worry me about this:
>   a_ i'm not quite sure of the mechanics of the multiple log files that 
> apache can generate, and which one(s) would have what you want -- or how 
> to intercept them
>   b_ i'm quite sure that there is a better way, that probably uses more 
> of the apache configuration powers of mod_perl, and not a crazy hack 
> like this
> 
> Again, I dont have much of an idea on this -- but no one else chimed up 
> and that tie to STDOUT really popped out in my memories when I read this 
> post.
> 
> 
> 
> On May 31, 2005, at 8:36 AM, Daniel B. Hemmerich wrote:
> 
>> Hello all...
>>
>> When a misconfiguration occurs, we receive a new line in the apache 
>> error logs that is not in the standard error log format (I assume 
>> since MP is writing to STDERR). Short of changing all of our scripts 
>> to properly log, is there a quicker method to accomplish the following 
>> change:
>>
>> Change this:
>>
>> Can't locate /www/path/goes/here//config.pl in @INC (@INC contains: 
>> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
>> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
>> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
>> at /www/example.com/cgi-bin/example.cgi line 64.
>>
>> To this:
>>
>> [Thu May 19 08:47:41 2005] [error] [MODULENAME Can't locate 
>> /www/path/goes/here//config.pl in @INC (@INC contains: 
>> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
>> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
>> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
>> at /www/example.com/cgi-bin/example.cgi line 64.
>>
>> Thanks in advance!
> 
> 

Re: Apache Error Log Format

Posted by Jonathan Vanasco <jv...@mastersofbranding.com>.
I really have no idea, but no one has chimed up on this, so I'll try to 
help (and maybe someone here can clear up my misconceptions)

MP writes to STDERR, BUT things can get weird because of the way 
apache2 handles error messages --

I could have this wrong, but mp errors and perl errors seem to go to 
the main apache error log ( on my system that's 
/usr/local/apache2/logs/error_log ).

When i specify a separate errorlog for a vhost, STDERR is directed there

I  don't know how to accomplish what you want , but I think I can help 
point you in a direction:

When I saw this post, i remembered how the default OSX apache2/mp had a 
specific compile time option that didn't 'print' to apache -- i think 
one had to call $r->print() instead of print, because of how STDOUT was 
directed.
	The 'fix' was either to recompile apache, or set up a perl handler to 
tie STDOUT to Apache

I'm found a post about this on google (not sure if its the 'right' one, 
i came across this 2 years ago):
	http://www.macosxhints.com/article.php?story=20031129120521712
		PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless tied 
*STDOUT; }"

Based on that, i *think* that you could probably write a handler that 
intercepts STDERR, rewrites it to your specifications, and 
ties/redirects it somewhere

But , two things worry me about this:
   a_ i'm not quite sure of the mechanics of the multiple log files that 
apache can generate, and which one(s) would have what you want -- or 
how to intercept them
   b_ i'm quite sure that there is a better way, that probably uses more 
of the apache configuration powers of mod_perl, and not a crazy hack 
like this

Again, I dont have much of an idea on this -- but no one else chimed up 
and that tie to STDOUT really popped out in my memories when I read 
this post.



On May 31, 2005, at 8:36 AM, Daniel B. Hemmerich wrote:

> Hello all...
>
> When a misconfiguration occurs, we receive a new line in the apache 
> error logs that is not in the standard error log format (I assume 
> since MP is writing to STDERR). Short of changing all of our scripts 
> to properly log, is there a quicker method to accomplish the following 
> change:
>
> Change this:
>
> Can't locate /www/path/goes/here//config.pl in @INC (@INC contains: 
> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
> at /www/example.com/cgi-bin/example.cgi line 64.
>
> To this:
>
> [Thu May 19 08:47:41 2005] [error] [MODULENAME Can't locate 
> /www/path/goes/here//config.pl in @INC (@INC contains: 
> /usr/local/lib/perl5/5.8.4/i686-linux /usr/local/lib/perl5/5.8.4 
> /usr/local/lib/perl5/site_perl/5.8.4/i686-linux 
> /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl .) 
> at /www/example.com/cgi-bin/example.cgi line 64.
>
> Thanks in advance!