RequestDumperFilterは、HTTPリクエストとレスポンスを記録するために使用されるTomcatログフィルタです。Tomcat 7:RequestDumperFilterがHTTPリクエスト/レスポンスボディをログに記録しない
私はthis documentationに従って、Tomcat用にorg.apache.catalina.filters.RequestDumperFilter
を設定しました。
ログが示すように、メッセージヘッダーが記録されているが、メッセージ本体がHTTP要求と応答の両方のログでは省略されている(様々なメッセージを用いて試験)
ドキュメントが必要logging.properties
設定を言及本文をログに記録する:
##レベルは少なくともINFOに設定する必要があります。本文をダンプする場合は、FINESTに設定してください。
org.apache.catalina.filters.RequestDumperFilter
class in the Apache SVN repositoryにメッセージ本文を記録する機能がないようです。
${catalina.base}/conf/logging.properties
:
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler, 1request-dumper.org.apache.juli.FileHandler
...
# 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 = FINEST
1request-dumper.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1request-dumper.org.apache.juli.FileHandler.prefix = request-dumper.
1request-dumper.org.apache.juli.FileHandler.formatter = org.apache.juli.VerbatimFormatter
org.apache.catalina.filters.RequestDumperFilter.level = FINEST
org.apache.catalina.filters.RequestDumperFilter.handlers = \
1request-dumper.org.apache.juli.FileHandler
${catalina.base}/conf/web.xml
:
...
<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>
...
${catalina.base}/logs/request-dumper.log
:
http-bio-8080-exec-9 START TIME =13-Jul-2017 15:08:40
http-bio-8080-exec-9 requestURI=/manager/html/upload
http-bio-8080-exec-9 authType=BASIC
http-bio-8080-exec-9 characterEncoding=UTF-8
http-bio-8080-exec-9 contentLength=615391
http-bio-8080-exec-9 contentType=multipart/form-data; boundary=----WebKitFormBoundaryP2bE0aVydgRqWbXP
http-bio-8080-exec-9 contextPath=/manager
http-bio-8080-exec-9 cookie=JSESSIONID=144935F6B43B3CB48AAD7E2980DC1E69
http-bio-8080-exec-9 header=host=localhost:8080
http-bio-8080-exec-9 header=connection=keep-alive
http-bio-8080-exec-9 header=content-length=615391
http-bio-8080-exec-9 header=cache-control=max-age=0
http-bio-8080-exec-9 header=authorization=Basic YWRtaW46Z29WYWx1ZTEyMyE=
http-bio-8080-exec-9 header=origin=http://localhost:8080
http-bio-8080-exec-9 header=upgrade-insecure-requests=1
http-bio-8080-exec-9 header=user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
http-bio-8080-exec-9 header=content-type=multipart/form-data; boundary=----WebKitFormBoundaryP2bE0aVydgRqWbXP
http-bio-8080-exec-9 header=accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
http-bio-8080-exec-9 header=referer=http://localhost:8080/manager/html/undeploy?path=/ReqRespDumpFilter&org.apache.catalina.filters.CSRF_NONCE=DDA08F1F9D404EE9E5631E9CA9528401
http-bio-8080-exec-9 header=accept-encoding=gzip, deflate, br
http-bio-8080-exec-9 header=accept-language=en-US,en;q=0.8
http-bio-8080-exec-9 header=cookie=JSESSIONID=144935F6B43B3CB48AAD7E2980DC1E69
http-bio-8080-exec-9 locale=en_US
http-bio-8080-exec-9 method=POST
http-bio-8080-exec-9 parameter=org.apache.catalina.filters.CSRF_NONCE=80714B6B625B708F2BB416747BEFB87E
http-bio-8080-exec-9 pathInfo=/upload
http-bio-8080-exec-9 protocol=HTTP/1.1
http-bio-8080-exec-9 queryString=org.apache.catalina.filters.CSRF_NONCE=80714B6B625B708F2BB416747BEFB87E
http-bio-8080-exec-9 remoteAddr=0:0:0:0:0:0:0:1
http-bio-8080-exec-9 remoteHost=0:0:0:0:0:0:0:1
http-bio-8080-exec-9 remoteUser=admin
http-bio-8080-exec-9 requestedSessionId=144935F6B43B3CB48AAD7E2980DC1E69
http-bio-8080-exec-9 scheme=http
http-bio-8080-exec-9 serverName=localhost
http-bio-8080-exec-9 serverPort=8080
http-bio-8080-exec-9 servletPath=/html
http-bio-8080-exec-9 isSecure=false
http-bio-8080-exec-9 ------------------=--------------------------------------------
http-bio-8080-exec-9 ------------------=--------------------------------------------
http-bio-8080-exec-9 authType=BASIC
http-bio-8080-exec-9 contentType=text/html;charset=utf-8
http-bio-8080-exec-9 header=Content-Type=text/html;charset=utf-8
http-bio-8080-exec-9 header=Transfer-Encoding=chunked
http-bio-8080-exec-9 header=Date=Thu, 13 Jul 2017 13:08:40 GMT
http-bio-8080-exec-9 remoteUser=admin
http-bio-8080-exec-9 status=200
http-bio-8080-exec-9 END TIME =13-Jul-2017 15:08:40
http-bio-8080-exec-9 ===============================================================