You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> on 2007/09/28 15:38:59 UTC

Apache2::Log - logging to error_log instead of stdout

When my filter is installed, i want to log some message to the server Log, 
like:

[Fri Sep 28 15:23:27 2007] [notice] suEXEC mechanism enabled 
(wrapper: /usr/sbin/suexec)


I thought i can use this:

sub DIR_CREATE {
     my $s = Apache2::ServerUtil->server;
     $s->log_serror( Apache2::Log::LOG_MARK, Apache2::Const::LOG_NOTICE,
         APR::Const::SUCCESS, "CAE-ResponseFilter enabled."
     );
}

The message is logged - but to "stdout - console" where i am starting apache  
like this: /etc/init.d/apache2 start ... no to the log file.
How can i log to this logfile?

Torsten

Re: Apache2::Log - logging to error_log instead of stdout

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Am Sonntag, 30. September 2007 schrieb Philippe M. Chiasson:
> Why not just report the module is available at startup, and report
> it's being used at run time from within an actual handler, not
> configuration hooks.

Good idea.
The second a got a idea how to "do", but the first - thats what i want to make 
within DIR_CREATE, which is the wrong way you told.
So - how can the first option - report that module is there - be done?

Torsten

Re: Apache2::Log - logging to error_log instead of stdout

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Torsten Krah wrote:
> When my filter is installed, i want to log some message to the server Log, 
> like:
> 
> [Fri Sep 28 15:23:27 2007] [notice] suEXEC mechanism enabled 
> (wrapper: /usr/sbin/suexec)
> 
> 
> I thought i can use this:
> 
> sub DIR_CREATE {
>      my $s = Apache2::ServerUtil->server;
>      $s->log_serror( Apache2::Log::LOG_MARK, Apache2::Const::LOG_NOTICE,
>          APR::Const::SUCCESS, "CAE-ResponseFilter enabled."
>      );
> }
> 
> The message is logged - but to "stdout - console" where i am starting apache  
> like this: /etc/init.d/apache2 start ... no to the log file.
> How can i log to this logfile?

Don't use DIR_CREATE as the context to log from. It's most likely executing
too soon for your purposes.

Apache2::ServerUtil->server when invoked at startup time will return you
the server object of the main server object, not likely what you want
either, so:

sub DIR_CREATE {
	my ($class, $param) = @_;
        my $s = $param->server;
        [...]

Would be more correct.

But ultimately, you want to report you are enabled not at DIR_CREATION
time for sure, more likely DIR_MERGE. But even then, you might have
to report this many, many times, if .htaccess files are enable for
instance.

Why not just report the module is available at startup, and report
it's being used at run time from within an actual handler, not configuration
hooks.

------------------------------------------------------------------------
Philippe M. Chiasson     GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/       m/gozer\@(apache|cpan|ectoplasm)\.org/