Is it possible to print all requests to Tomcat and responses from Tomcat in a logfile?
ex:
request
headers: [header1=a, header2=a]
params: [param1=avv, param2=b]
response
status-code = 200
response = its works
Is it possible to print all requests to Tomcat and responses from Tomcat in a logfile?
ex:
request
headers: [header1=a, header2=a]
params: [param1=avv, param2=b]
response
status-code = 200
response = its works
Put an
AccessLogValve
in theHost
orContext
element e.g.:The
pattern
attribute can take one of two shorthand values (common,combined) or a custom pattern using a number of constants and replacement strings. Let me quote the Tomcat docs:https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Log_Valve
As you can see there are quite a few fields that can be used, but if you still need more, you have to write your own
AccessLogValve
implementation.David Lee says add this to your
server.xml
:<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
but, I guess that is tomcat 6; this answer shows how to use
Request_Dumper_Filter
in tomcat 7 https://stackoverflow.com/a/8727615/1763984https://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Request_Dumper_Filter
The Request Dumper Filter logs information from the
request
andresponse
objects and is intended to be used for debugging purposes.The following entries in a web application's
web.xml
would enable the Request Dumper filter for all requests for that web application.If the entries were added to
CATALINA_BASE/conf/web.xml
, the Request Dumper Filter would be enabledfor all web applications
.