Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tomcat log request parameters

Is there a way to log request parameters in Tomcat?

If so, how?

Thanks.

like image 346
Alex Baranosky Avatar asked Jun 06 '26 06:06

Alex Baranosky


2 Answers

Tomcat has a RequestDumperFilter that can be used to dump the request, including parameters.

Alternatively, if you prefer to change your server config rather than the webapp, there is the RequestDumperValve.

Both are described in the Apache Tomcat Configuration Reference.

like image 165
mdma Avatar answered Jun 08 '26 19:06

mdma


@mdma is right. However a word of caution is necessary if your webapp depends on correct handling of UTF-8 query parameters in the URL.

The recommended way for a Tomcat webapp to ensure that UTF-8 characters in URLs are handled correctly in query parameters is to add a filter to the webapp to set the encoding type on the request. This filter has to do its stuff before anything triggers parsing of the parameters. Unfortunately, Tomcat valves (such as the wonderfully useful RequestDumperValve) operate before the request hits the webapp's filters. This causes the query parameters to be parsed assuming Latin-1 encoding ... and the damage is done.

This page is a good summary of character coding issues in Tomcat.

like image 27
Stephen C Avatar answered Jun 08 '26 21:06

Stephen C