tomcat log request parameters
Is there a way to log req开发者_如何转开发uest parameters in Tomcat?
If so, how?
Thanks.
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.
@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.
精彩评论