Custom interceptor to obtain a detailed log of the application's requests and responses and simple error handling.
.
├── dto # DTO example (Request and Response)
├── exception # Exception Handler
│ ├── controller # Rest Advice Controller
│ ├── dto # DTO response for exception handling
├── interceptor # Interceptor config
│ ├── dto # Logger DTO
│ ├── service # Service to log trace
├── web # Rest Controller
- method : { GET, POST, PUT, PATCH, OPTIONS, DELETE }
- ip : Request Ip Adrress
- path : Request URI
- parametersIn : Parameters of request (@RequestBody or @RequestParam)
- parametersOut : Body of response
- codeResponse : HTTP status
- timeResponse : Response time of service
- URL Endpoint: http://127.0.0.1:8010/interceptor/v1/test
- Port: 8010
- Context path: /interceptor/v1
- Clone repository.
- Open folder.
- Run:
mvn clean && mvn install
- Open in your favorite IDE (I use Intellij Idea).
- Use postman or SoapUI to test.
An example of output.
LOG{
"method":"DELETE",
"ip":"127.0.0.1",
"path":"/interceptor/v1/test",
"parametersIn":{},
"parametersOut":
{
"code":"400","message":"Missing parameter: id"
},
"codeResponse":400,
"timeResponseService":"69 ms"
}