You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Oliver Graute <ol...@gmail.com> on 2017/08/23 10:34:32 UTC

[users@httpd] Prefix Apache Traces with Part of the Url

Hello list,

I try to customize my apache logs.

currently I have this setting:

LogFormat "%<U %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%<U %h %l %u %t \"%r\" %>s %b" common

resulting in this log format:

/iDM/iDM.php 10.0.0.98 - - [23/Aug/2017:11:20:18 +0200] "POST /iDM/iDM.php HTTP/1.1" 401 -
/iAPI/db 10.0.0.98 - - [23/Aug/2017:11:21:08 +0200] "GET /iAPI/db HTTP/1.1" 200 175


What i like to have is something where only part of the URL String is prefixed for
every entry. Like this:


iDM: 10.0.0.98 - - [23/Aug/2017:11:20:18 +0200] "POST /iDM/iDM.php HTTP/1.1" 401 -
iAPI: 10.0.0.98 - - [23/Aug/2017:11:21:08 +0200] "GET /iAPI/db HTTP/1.1" 200 175

is such format possible?

Best Regards,

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Prefix Apache Traces with Part of the Url

Posted by Oliver Graute <ol...@gmail.com>.
On 23/08/17, Eric Covener wrote:
> > What i like to have is something where only part of the URL String is prefixed for
> > every entry. Like this:
> >
> >
> > iDM: 10.0.0.98 - - [23/Aug/2017:11:20:18 +0200] "POST /iDM/iDM.php HTTP/1.1" 401 -
> > iAPI: 10.0.0.98 - - [23/Aug/2017:11:21:08 +0200] "GET /iAPI/db HTTP/1.1" 200 175
> >
> > is such format possible?
> 
> You can grab part of the URL and put it in a new environment variable:
> 
> # Optional: make sure we always have something
> SetEnvIf Request_URI (.*) my-ctx=$1
> # Try to grab something context-root like
> SetEnvIf Request_URI ^/+([^/]+)/ my-ctx=$1
> 
> Then add this to your current CustomLog or LogFormat
> 
> %{my-ctx}e

this braught me to the right track.

Thanks,

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Prefix Apache Traces with Part of the Url

Posted by Eric Covener <co...@gmail.com>.
> What i like to have is something where only part of the URL String is prefixed for
> every entry. Like this:
>
>
> iDM: 10.0.0.98 - - [23/Aug/2017:11:20:18 +0200] "POST /iDM/iDM.php HTTP/1.1" 401 -
> iAPI: 10.0.0.98 - - [23/Aug/2017:11:21:08 +0200] "GET /iAPI/db HTTP/1.1" 200 175
>
> is such format possible?

You can grab part of the URL and put it in a new environment variable:

# Optional: make sure we always have something
SetEnvIf Request_URI (.*) my-ctx=$1
# Try to grab something context-root like
SetEnvIf Request_URI ^/+([^/]+)/ my-ctx=$1

Then add this to your current CustomLog or LogFormat

%{my-ctx}e

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org