2

I have a Java Springboot application and want to log the HTTP request body. I managed to do it by setting the field logging.level.org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor = DEBUG in my application.properties. This create a nice log like that when I get a request:

2020-04-27T10:12:46,041 DEBUG 40422 --- [-nio-443-exec-2] RequestResponseBodyMethodProcessor  : Read "application/json;charset=UTF-8" to ["{
    "cpName":"SSA, Test 1",
    "contractId":"1234567",
    "contractName":"SSA, Contract 1",
    "scnName":" (truncated)...]

However, only the beginning of the body is shown. I don't have the value for the field scnName and there is another field after this one called description that does not appears either. I search but could not find a way to write the whole body in the log. Is there any settings to change to print everything?

Thank you in advance.

3
  • Please go through : baeldung.com/spring-http-logging Commented Apr 27, 2020 at 10:03
  • @R.G I don't see anything related to this problem in this page. Did I miss something? Commented Apr 27, 2020 at 12:03
  • Sorry for that , setting log level for RequestResponseBodyMethodProcessor didn’t look like the correct way to log request body , hence the link . I do not have a solution for the log message getting trimmed Commented Apr 27, 2020 at 13:27

1 Answer 1

16

Set the logging level to TRACE:

logging.level.org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor=TRACE

Source: SPR-17254 (#21787)

The logging of encoded and decoded values, for both Spring MVC and WebFlux, now logs the full value at TRACE, and up to 100 chars at DEBUG. ...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.