-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jeff,

On 2/14/15 6:46 AM, Jeff Kohut wrote:
> On Fri, Feb 13, 2015 at 10:29 AM, Christopher Schultz < 
> ch...@christopherschultz.net> wrote:
> 
> Jeff,
> 
> On 2/13/15 10:28 AM, Jeff Kohut wrote:
>>>> I am running Tomcat  7.0.54 on a Windows 2008 R1 with SP1 
>>>> platform.
>>>> 
>>>> I would like to control the contents of what gets logged to
>>>> the Tomcat localhost_access_log
>>>> 
>>>> specifically , I would like to remove logging of entries like
>>>> :
>>>> 
>>>> 10.239.54.8 - - [13/Feb/2015:00:00:07 -0600] "GET /atb
>>>> HTTP/1.0" 200 573 10.239.58.29 - - [13/Feb/2015:00:00:08
>>>> -0600] "GET /atb HTTP/1.0" 200 561
>>>> 
>>>> we have some external load balancers and server monitoring 
>>>> software periodically hitting the application web page to see
>>>> if it is responding. I would like to know how remove these
>>>> entries to reduce the amount of "noise" that is in the
>>>> localhost_access_log log file, but allow other entries (i.e.
>>>> from OTHER IP addresses or with other functions like "POST"
>>>> or other strings like "HTTP/1.1"
>>>> 
>>>> I have examined the information at the below link
>>>> (unfortunately there is no example there with detail on what
>>>> I am attempting to do).
>>>> 
>>>> http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html
>>>> 
>>>> Seems like I want to use the valve Access Log Valve
>>>> Attributes:
>>>> 
>>>> conditionIf
>>>> 
>>>> or
>>>> 
>>>> conditionUnless
>>>> 
>>>> options from valve documentation, but it is not clear to me
>>>> how to do this (if this is the correct way ?).
> 
> Yep, this is what you are looking for.
> 
>>>> Server.xml currently has the following setup configuration:
>>>> 
>>>> <!-- Access log processes all example. Documentation at: 
>>>> /docs/config/valve.html Note: The pattern used is equivalent
>>>> to using pattern="common" --> <Valve 
>>>> className="org.apache.catalina.valves.AccessLogValve" 
>>>> directory="logs" prefix="localhost_access_log."
>>>> suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
>>>> 
>>>> Is it possible to do this without programming (i.e. can I set
>>>> the valve components to simply filter on an ip address or key
>>>> word string (i.e. "Get /atb HTTP/1.0" and if that value is
>>>> found in the request, can I chose to then NOT write that
>>>> entry to the AccessLogValve). I have searched pretty
>>>> thoroughly for some time on how to do this, but the
>>>> documentation simply does not provide enough of an example on
>>>> how to do this. I am not a programmer, but would think that
>>>> filtering entries out of logs based on criteria would be a
>>>> valuable feature to have.
> 
> You have to have a way to set (or not) a request attribute in order
> to use conditionIf/conditionUnless. One way to do it without
> writing any of your own code is to use url-rewrite, which is more
> like url-do-whatever: http://tuckey.org/urlrewrite/
> 
> You can configure that to set request attributes under certain 
> criteria. Just have it set (or not) whatever attribute name you
> use for your conditional logging and you should be good to go.
> 
> Hope that helps, -chris
> 
> 
>> Chris, Looks a bit complicated (but then I guess life is a bit
>> complicated ;-) I was hoping for something built in. In looking
>> at the explanation and a little at the support websites, it looks
>> as if this is something to rewrite what makes it to the actual
>> webapps applications.

It does both: AccessLogValve's "conditionIf/conditionUnless" consult
request attributes to decide if logging should be performed.
url-rewrite can inject request attributes given certain request
criteria (like resource URL, just like you asked) without writing any
code: it's just configuration of the latter to control the behavior of
the former.

>> I did not see where it was used to be able to filter out the main
>>  tomcat access logs (i.e being able to control something so early
>> as the Request and built in Tomcat logging), but I guess it may
>> be possible to do that. I will look into this further if I have
>> the time. As Andre pointed out in a follow up post, I could just
>> filter the access log into another file externally and do my
>> cleanup that way.

Post-processing the log file is definitely the best option for a
high-volume site: you'll save all the processing time you are
"wasting" on deciding whether or not to log each request. Then again,
the act of logging itself has performance consequences...

Access logs are written *after* the request has completed, so if you
alter the request during processing, the post-execution log-writer can
decide whether or not to log the request even after Filter code runs.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU4f0QAAoJEBzwKT+lPKRYYyIQAI/UkR/oJ1fMh9BaWiFCe0QY
3qA9fZM4RXxc9fnGXqHmy26x9iCxx6lLcew8kZPfr3iWeqyP2nQihGBaxOHB+/ea
6BQuNQVifAqIuSX0IUgJG3FnbltBNNu8HY7/Mvu+jGbK4UvwzJy8zpLlgzI+hxjM
H5zcmUDZc/DKRxiEY+bsdUjn6G1Mn5kYIBrIFJl8FJGQHgCzlhABnqQe5+F4rUOJ
Iqlfd8A38rbvdjcOwOW5E078WC0FRuhe2dhRknN7d8CpaMtiR+IDVUIfo3XvXUcc
Ti5DQEjBil6y5MDeO9UDrnntXx0/cC3KTMCvm7fk0/RV8wOauLmrW/v/9QFielkj
iA+2FwsJgOENc9Z9Lc5srit4qJhI6clAxnTnsjDIJc9uh3Znr0xxvvWKx07C85X5
K+FtRGPmMsVl2u0r/4R+jqQxqKLp6EZ3B5w3qegRVZf8JzxMZUcIksr5WriiQe3a
dfCdFl9m1vxiJtDwGEwwOF/TottR59cW2t2is9IIQQdNQmxqcSzxs7HdA3x1QMR8
Ztteq3nhx96pDX4eX6AB0xOKnhxGaEtYY/Wzovtch+g5uOH6YX6VDnSNAt/r0OVQ
S0g/zxuJJkOnoJUqYdFFTFDXaZVvXDUKQ0daXal25YbZf8UFSeLCnMa6v6DCUFLa
2mZiFdacLO0i8/1W9nqQ
=xFUV
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to