Sent from my tablet.
On Feb 17, 2015 7:22 AM, "Rainer Jung" <rainer.j...@kippdata.de> wrote:
>
> Am 14.02.2015 um 18:44 schrieb Jeff Kohut:
>
>> Sent from Google Nexus Phone
>> On Feb 14, 2015 9:54 AM, "Rainer Jung" <rainer.j...@kippdata.de> wrote:
>>>
>>>
>>> Am 14.02.2015 um 12:46 schrieb Jeff Kohut:
>>>
>>>> On Fri, Feb 13, 2015 at 10:29 AM, Christopher Schultz <
>>>> ch...@christopherschultz.net> wrote:
>>>>
>>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>>> Hash: SHA256
>>>>>
>>>>> 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. 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.
>>>> Thank you for taking the time to answer and provide something to look
>>
>> into
>>>>
>>>> further.
>>>
>>>
>>>
>>> I basically agree with André. And the URL rewrite filter is a nice and
>>
>> powerful tool that's useful to learn about, although it can't be easily
>> integrated into a webapp from the outside (not moving it into the webapp
>> itself).
>>>
>>>
>>> If it happens that between your load balancer and Tomcat there is
already
>>
>> an Apache web server and the forwarding from Apache to Tomcat is done by
>> mod_jk, then you can set Tomcat request attributes from mod_jk by using
>> JkSetEnv. You would use a RewriteRule probably with a RewriteCond to set
an
>> Apache environment variable for the requests that come from the LB, then
>> use JkEnvVar to forward that variable, then use the conditionUnless for
the
>> Tomcat access log valve to suppress those requests. Using a seconds
>> AccessLogValve with conditionIf would let you log those requests to a
>> second log file.
>>>
>>>
>>> I'm not saying that I would inject a new Apache/mod_jk into the picture
>>
>> just for that feature. But if it were already there ...
>>>
>>>
>>> Regards,
>>>
>>> Rainer
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>>
>> All good thoughts, but no Apache.  If it can't be done in Tomcat, I will
>> likely just live without.
>
>
> Triggered by another post today: Starting with Tomcat 8 there's the
RewriteValve:
>
> http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
>
> And that is able to set request attributes via configuration. Look for
"ENV" and "environment variable" because the RewriteValve was modelled
after Apache httpd mod_rewrite, where the notion is environment variable.
In Servlet land this was interpreted by the valve as request attribute.
>
> Totally forgot about it.
>
>
> Regards,
>
> Rainer

Thanks for pointing out the option in Tomcat 8. I will look at it.  I now
have few options. Thanks to all for ideas.
Jeff
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>

Reply via email to