It took me long enough time to find out, so I thought I would make a post for anyone else who is after the answer in the future.
In Groovy code:
log.debug("ElasticSearch Query using Java Client API:\n${searchRequestBuilder.internalBuilder()}")
And this in Java:
log.debug("ElasticSearch Query using Java Client API:\n" + searchRequestBuilder.internalBuilder());
The output is prettified by default.