Skip to content

tufangorel/spring-boot-aspect-annotation-log-method-in-out-parameters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-boot-aspect-annotation-log-method-in-out-parameters

1- Log to the console execution time for a restController method annotated with LogMethodExecutionTime from @Around advice.

Tech Stack

Java 11
H2 Database Engine
spring boot
spring data jpa
spring web
spring aspects
hibernate
logback
maven
junit

API OPERATIONS

Save customer sucessfully to database

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: -------------------------------

About

spring-boot-aspect-annotation-log-method-in-out-parameters

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages