Questions tagged «spring-rest»

21
Spring Boot-如何在一个地方记录所有带有异常的请求和响应?
我正在使用Spring Boot开发Rest API。我需要使用输入参数(使用方法,例如GET,POST等),请求路径,查询字符串,此请求的相应类方法,此操作的响应(成功和错误)记录所有请求。 例如: 成功的请求: http://example.com/api/users/1 日志应如下所示: { HttpStatus: 200, path: "api/users/1", method: "GET", clientIp: "0.0.0.0", accessToken: "XHGu6as5dajshdgau6i6asdjhgjhg", method: "UsersController.getUser", arguments: { id: 1 }, response: { user: { id: 1, username: "user123", email: "user123@example.com" } }, exceptions: [] } 或有错误的要求: http://example.com/api/users/9999 日志应该是这样的: { HttpStatus: 404, errorCode: 101, path: "api/users/9999", …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.