Inital important hint, especially for production environments: be careful enabling the filter since it may harm your request param encoding! So maybe be sure to set up everything right by maybe setting up the org.apache.catalina.filters.SetCharacterEncodingFilter first!
From Tomcat 7+ on you should do it via filters:
<filter>
<filter-name>requestdumper</filter-name>
<filter-class>
org.apache.catalina.filters.RequestDumperFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>requestdumper</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
and then log it e.g. to some special log file like this in CATALINA_BASE/conf/logging.properties
(modified based on Tomcat 7 docs):
## this may likely be your (to-be-updated) orig handlers declaration:
#handlers = \
# 1catalina.org.apache.juli.AsyncFileHandler\
# ,2localhost.org.apache.juli.AsyncFileHandler\
# ,3manager.org.apache.juli.AsyncFileHandler\
# ,4host-manager.org.apache.juli.AsyncFileHandler\
# ,java.util.logging.ConsoleHandler
## ... and you have to add your 1request-dumper:
handlers = \
1request-dumper.org.apache.juli.FileHandler\
,1catalina.org.apache.juli.AsyncFileHandler\
,2localhost.org.apache.juli.AsyncFileHandler\
,3manager.org.apache.juli.AsyncFileHandler\
,4host-manager.org.apache.juli.AsyncFileHandler\
,java.util.logging.ConsoleHandler
## ...
# To this configuration below, 1request-dumper.org.apache.juli.FileHandler
# also needs to be added to the handlers property near the top of the file
1request-dumper.org.apache.juli.FileHandler.level = INFO
1request-dumper.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1request-dumper.org.apache.juli.FileHandler.prefix = localhost_access_log.req-dumps.
1request-dumper.org.apache.juli.FileHandler.encoding = UTF-8
1request-dumper.org.apache.juli.FileHandler.formatter = org.apache.juli.VerbatimFormatter
org.apache.catalina.filters.RequestDumperFilter.level = INFO
org.apache.catalina.filters.RequestDumperFilter.handlers = \
1request-dumper.org.apache.juli.FileHandler
Till Tomcat 6 and before you could use the RequestDumperValve
(as in Brian's answer):
add this to your server.xml
:
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>