tomcat8tomcat-valve

Tomcat 8 Log when http body finishes write; ServletOutputStream closes? Valve %D?


I have a WAR file I am deploying in Tomcat 8. It is using Spring Boot, which is pretty much incidental.

I want to log how long it takes for the client to finish consuming my http responses, since the bodies of my responses are large. That means the filter chain has completed long before--sometimes minutes before--the HttpServletResponse's ServletOutputStream has been fully consumed by the client.

Does Tomcat Valve %D cover this case? https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Log_Valve/Attributes I am not sure from reading the documentation.

If not, how can I capture it? I basically want to log a timestamp when the ServletOutputStream.close() is called, right? How can I do that?


Solution

  • The best solution I have found is to put a load balancer in front of my tomcat (haproxy) switch it to HTTP mode, and log it that way. I however much prefer TCP routing, since it is measurably faster for my use case. Any other suggestions?