4

I trying to investigate how often a particular HTTP request is getting send to a web site. The request is a POST and has a parameter named "_method". I can see this in firebug getting net over.

I need to check the value of this "_method" parameter, so following the documentation http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access_Log_Valve I add the following to the tomcat access configuration for the valve

%{_method}r

But it is not coming out in access logs.

I wonder is that because of the underscore?

Note, the parameter name cannot be changed.

dublintech
  • 16,815
  • 29
  • 84
  • 115

2 Answers2

7

OK, What I had to do was use the ExtendedAccessLogValve.

I added the below to my server.xml

    <Valve className="org.apache.catalina.valves.ExtendedAccessLogValve" directory="logs" pattern="c-dns x-H(remoteUser) date time cs-method cs-uri x-H(protocol) sc-status bytes x-P(_method)" prefix="localhost_extended_access_log." resolveHosts="false" suffix=".txt"/>

The part x-P(_method) is the crucial part which gave it to me.

I am including answer for any on-lookers.

dublintech
  • 16,815
  • 29
  • 84
  • 115
2
%{xxx}r 

is used for an "attribute in the ServletRequest" not for HTTP parameters (which are what I assume you mean, if you can see it in Firebug). ServletRequest attributes will be entirely server-side, so you would not be able to see them in Firebug.

If you want to output HTTP parameters (and it's not a GET, ie. they are in the URL) I think you would have to use Request Dumper Valve documented on that same page.

Difference between getAttribute() and getParameter() explains the difference if the above is not clear.

Community
  • 1
  • 1
matt freake
  • 4,877
  • 4
  • 27
  • 56