If you're only interested in printing the response body if an error occur then you can use:
make sure you are using .log().ifError() just after than otherwise logs will not show. It logs everything only if an error occurs (status code >= 400).
REST Assured Log only the status
REST Assured Log if status code is equal to
log if the status code matches the supplied Hamcrest matcher