1- Log to the console execution time for a restController method annotated with LogMethodExecutionTime from @Around advice.
Java 11
H2 Database Engine
spring boot
spring data jpa
spring web
spring aspects
hibernate
logback
maven
junit
Method : HTTP.POST
URL : http://localhost:8080/customer/save
Request :
{ "name":"name1", "age":1, "addresses":[ {"streetName":"software","city":"ankara","country":"TR"} ] }
Response :
HTTP response code 200
{ "id": 1, "name": "name1", "age": 1, "addresses": [ { "id": 1, "streetName": "software", "city": "ankara", "country": "TR" } ] }
Console log message : com.company.customerinfo.config.aspect.LoggingAspect: ------------------------------- com.company.customerinfo.config.aspect.LoggingAspect: Start Log for @Around advice execution for LogMethodExecutionTime annotation com.company.customerinfo.config.aspect.LoggingAspect: Total time for method execution com.company.customerinfo.controller.CustomerController.save took --> 184 ms com.company.customerinfo.config.aspect.LoggingAspect: Method Input Parameters : {customer=Customer{id=1, name='name1', age=1, addresses=[Address{id=1, streetName='software', city='ankara', country='TR'}]}} com.company.customerinfo.config.aspect.LoggingAspect: Method Output Parameters : <200 OK OK,Customer{id=1, name='name1', age=1, addresses=[Address{id=1, streetName='software', city='ankara', country='TR'}]},[]> com.company.customerinfo.config.aspect.LoggingAspect: End Log for @Around advice execution for LogMethodExecutionTime annotation com.company.customerinfo.config.aspect.LoggingAspect: -------------------------------