Skip to content
Advertisement

How to log time taken by Rest web service in Spring Boot?

I am writing a web Rest web service using Spring Boot.

I want to log time taken by my webservice to process request. Also I want to log headers,method and URI called.

I have done similar in my jersey web service few months back using ContainerRequestFilter and ContainerResponseFilter filter() method.

Also, AOP is Better or Filter?

Advertisement

Answer

Have you tried with a basic filter like this?

JavaScript

EDITED: (Thanks @suren-aznauryan) Now, It uses Instant and Duration and avoids System.currentTimeMillis().

JavaScript
Advertisement