I developed a web application following the technology.
- Spring boot(undertow starter) : 1.4.2
- Java 7
- OS : Centos
- Servlet Filter : org.spring.web.filter.OncePerRequestFilter
in step 4 the filter is used to print http request/response info log. This data includes :
- (a)http url
- (b)Request body
- (c)Response Body
- (d)Response time.
Problem arised with (d) response time. However, Most of the response time is ok. But for few http request and respone i found log with negative response time(e.g -1024ms).
Here i calculated the http response time manually inside Servlet Filter
protected void doFilterInternal(...){
long startTime = System.currentTimeMillis();
..
some code
filterChain.doFilter(httpRequest,httpResonse);
...
long endTime = System.currentTimeMillis();
long responseTime = endTime - startTime
log.debug(responseTIme); [SLF4J logger,logback.xml]
}