REST Assured: Log if Error or if the status code matches some value
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).
Log only the status
Log is status code is equal to
log if the status code matches the supplied Hamcrest matcher