If I define a response entity class and return it by my rest controller, controller will change this class to json string. I want to log this json string, how to do it? Thanks.
For example:
Response entity class:
@Data
@AllArgsConstructor
public class ResponseEntity {
String code;
String message;
}
Rest Controller:
@RestController
@RequestMapping("/")
public class StudentController {
@RequestMapping("test")
public ResponseEntity test(){
return new ResponseEntity(200,"success");
}
}
I want to record this json response in log
{"code":200,"message":"success"}