Re: How to access the request URL in a custom valve implementation?
See AbstractAccessLogValve (which AccessLogValve overrides) Then you could override AbstractAccessLogValve.createAccessLogElement() which has case 'q': return new QueryElement(); To possible do doing something like case 'q': return new ObfuscatedQueryElement(); Where ObfuscatedQueryElement is much like the existing QueryElement with your additional requirements. They both would implement AccessLogElement which has access to the Request object -Tim On Fri, Jan 26, 2024 at 7:58 AM Manak Bisht wrote: > I want to obfuscate values of query params for certain URLs, however, I > would still like to log the request. Therefore, I cannot use the existing > conditionif/conditionunless attributes that AccessLogValve provides. > >
Re: How to access the request URL in a custom valve implementation?
I want to obfuscate values of query params for certain URLs, however, I would still like to log the request. Therefore, I cannot use the existing conditionif/conditionunless attributes that AccessLogValve provides. Sincerely, Manak Bisht On Fri, Jan 26, 2024 at 6:18 PM Mark Thomas wrote: > On 26/01/2024 10:46, Manak Bisht wrote: > > Hi, > > I am trying to extend the AccessLogValve to modify logging behaviour for > > certain URLs. However, I don't have access to the request object in the > > AccessLogValve API. So, I am left with regex matching on the > CharArrayWriter > > message object. Is there a better way to do this? > > It depends what you are trying to do - which you haven't explained. > > You have direct access to the request object in the invoke() method. > > Mark > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
Re: How to access the request URL in a custom valve implementation?
On 26/01/2024 10:46, Manak Bisht wrote: Hi, I am trying to extend the AccessLogValve to modify logging behaviour for certain URLs. However, I don't have access to the request object in the AccessLogValve API. So, I am left with regex matching on the CharArrayWriter message object. Is there a better way to do this? It depends what you are trying to do - which you haven't explained. You have direct access to the request object in the invoke() method. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How to access the request URL in a custom valve implementation?
My bad - AccessLogValve also supports that feature too - *%{xxx}r* write value of ServletRequest attribute with name xxx (escaped if required, value ?? if request is null) https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Access_Logging -Tim On Fri, Jan 26, 2024 at 7:23 AM Tim Funk wrote: > It depends on what you are trying to accomplish. ExtendedAccessLogValve is > a > little more flexible where you can write out arbitrary request > attributes but still format the request like the standard access > log. So you could have a filter set the value and not need to > write your own access logger. > > -Tim > > On Fri, Jan 26, 2024 at 5:47 AM Manak Bisht > wrote: > >> Hi, >> I am trying to extend the AccessLogValve to modify logging behaviour for >> certain URLs. However, I don't have access to the request object in the >> AccessLogValve API. So, I am left with regex matching on the >> CharArrayWriter >> message object. Is there a better way to do this? >> >
Re: How to access the request URL in a custom valve implementation?
It depends on what you are trying to accomplish. ExtendedAccessLogValve is a little more flexible where you can write out arbitrary request attributes but still format the request like the standard access log. So you could have a filter set the value and not need to write your own access logger. -Tim On Fri, Jan 26, 2024 at 5:47 AM Manak Bisht wrote: > Hi, > I am trying to extend the AccessLogValve to modify logging behaviour for > certain URLs. However, I don't have access to the request object in the > AccessLogValve API. So, I am left with regex matching on the > CharArrayWriter > message object. Is there a better way to do this? >
How to access the request URL in a custom valve implementation?
Hi, I am trying to extend the AccessLogValve to modify logging behaviour for certain URLs. However, I don't have access to the request object in the AccessLogValve API. So, I am left with regex matching on the CharArrayWriter message object. Is there a better way to do this? Sincerely, Manak Bisht