Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to get request parameter out to access log in tomcat

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.

like image 791
dublintech Avatar asked Jan 17 '23 05:01

dublintech


1 Answers

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.

like image 109
dublintech Avatar answered Jan 30 '23 03:01

dublintech