Tag: springrest

春季启动 – 如何在一个地方logging所有请求和exception的例外情况?

我正在与春季启动restAPI。 我需要用input参数(方法,如GET,POST等),请求path,查询string,对应的这个请求的类方法,以及这个动作的响应,成功和错误logging所有的请求。 举个例子: 成功的要求: 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", method: "GET", clientIp: "0.0.0.0", accessToken: "XHGu6as5dajshdgau6i6asdjhgjhg", […]