You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ben RUBSON <be...@gmail.com> on 2016/12/28 21:24:56 UTC

log_error and client IP

Hello,

I'm using the following to log error messages from mod_perl to Apache log files :
$r->log_error("mymsg");

It produces the following :
[Sat Dec 24 09:39:43.933388 2016] [:error] [pid 8015] mymsg

I'm a little bit suprised that it does not produce the following :
[Sat Dec 24 09:39:43.933388 2016] [:error] [pid 8015] [client 1.2.3.4:32133] mymsg

Why don't we have the [client] part with the client IP, as for every Apache error message ?

Thank you very much !

Ben


Re: log_error and client IP

Posted by Ben RUBSON <be...@gmail.com>.
> On 29 Dec 2016, at 17:26, Vincent Veyron <vv...@wanadoo.fr> wrote:
> 
> On Wed, 28 Dec 2016 22:24:56 +0100
> Ben RUBSON <be...@gmail.com> wrote:
> 
> 
>> I'm using the following to log error messages from mod_perl to Apache log files :
>> $r->log_error("mymsg");
>> 
>> It produces the following :
>> [Sat Dec 24 09:39:43.933388 2016] [:error] [pid 8015] mymsg
>> 
>> I'm a little bit suprised that it does not produce the following :
>> [Sat Dec 24 09:39:43.933388 2016] [:error] [pid 8015] [client 1.2.3.4:32133] mymsg
>> 
>> Why don't we have the [client] part with the client IP, as for every Apache error message ?
>> 
> 
> Not every Apache error message has that; for instance ssl errors in my logs don't have it either.

Yes you're right, but most or request related errors have this info :
[Fri Dec 30 13:57:16 2016] [error] [client 1.2.3.4] client denied by server configuration: /var/www/robots.txt
[Fri Dec 30 14:09:31 2016] [error] [client 1.2.3.4] script '/var/www/wp-login.php' not found or unable to stat
[Fri Dec 30 14:36:03 2016] [error] [client 1.2.3.4] user bob not found: /
[Fri Dec 30 14:36:25 2016] [error] [client 1.2.3.4] user alice: authentication failure for "/": Password Mismatch
[Fri Dec 30 13:40:23 2016] [error] [client 1.2.3.4] File does not exist: /var/www/favicon.ico
[Fri Dec 30 00:00:04 2016] [error] [client 1.2.3.4] client sent HTTP/1.1 request without hostname
[Thu Dec 29 17:13:41 2016] [error] [client 1.2.3.4] Directory index forbidden
[Wed Dec 28 09:43:59 2016] [error] [client 1.2.3.4] Invalid URI in request GET
etc...

> you can use :
> 
> $r->log_rerror(Apache2::Log::LOG_MARK(), Apache2::Const::LOG_WARNING, APR::Const::ENOTIME, "mymsg");
> 
> which outputs :
> 
> [Thu Dec 29 17:11:27.040549 2016] [perl:warn] [pid 7811] (20007)No time was provided and one was required.: [client 127.0.0.1:58886] mymsg, referer: http://ppro.libremen.com/
> 
> See :
> 
> https://perl.apache.org/docs/2.0/api/Apache2/Log.html#C____r_E_gt_log_rerror___

Thank you very much Vincent !
It works as expected :
[Fri Dec 30 14:32:05.175064 2016] [perl:warn] [pid 48723] [client 127.0.0.1:33045] mymsg

As there is no output example, I did not test more than the first proposed function :
$r->log_error(@message);
My mistake :)

Thank you again Vincent !

Best regards,

Ben


Re: log_error and client IP

Posted by Vincent Veyron <vv...@wanadoo.fr>.
On Wed, 28 Dec 2016 22:24:56 +0100
Ben RUBSON <be...@gmail.com> wrote:


> I'm using the following to log error messages from mod_perl to Apache log files :
> $r->log_error("mymsg");
> 
> It produces the following :
> [Sat Dec 24 09:39:43.933388 2016] [:error] [pid 8015] mymsg
> 
> I'm a little bit suprised that it does not produce the following :
> [Sat Dec 24 09:39:43.933388 2016] [:error] [pid 8015] [client 1.2.3.4:32133] mymsg
> 
> Why don't we have the [client] part with the client IP, as for every Apache error message ?
> 

Not every Apache error message has that; for instance ssl errors in my logs don't have it either :
 
[Tue Dec 27 20:14:25.730665 2016] [ssl:error] [pid 3243] AH02033: No hostname was provided via SNI for a name based virtual host

you can use :

$r->log_rerror(Apache2::Log::LOG_MARK(), Apache2::Const::LOG_WARNING, APR::Const::ENOTIME, "mymsg");

which outputs :

[Thu Dec 29 17:11:27.040549 2016] [perl:warn] [pid 7811] (20007)No time was provided and one was required.: [client 127.0.0.1:58886] mymsg, referer: http://ppro.libremen.com/

See :

https://perl.apache.org/docs/2.0/api/Apache2/Log.html#C____r_E_gt_log_rerror___

(note : there appears to be a typo in the example, missing parentheses after LOG_MARK)


-- 
					Bien à vous, Vincent Veyron 

https://marica.fr/
Gestion des sinistres assurances, des dossiers contentieux et des contrats pour le service juridique