I am using elastic4s v6.5.2 to send pretty simple index/update requests to ElasticSearch.
elastic4s uses com.elasticsearch.client.RestClient under the hood, which seems to support response logging.
My goal is to incorporate these logs in my application (write them to a file/stdout).
In my project, I am using logback as the logging framework, whereas elasticsearch (and subsequently its RestClient) uses commons-logging, as far as I understand.
I have tried:
- Adding a new
<logger>in my logback configuration
(both for the packagename="org.elasticsearch.clientand the specific classname="org.elasticsearch.client.RestClient") Adding a
commons-logging.propertiesfile into my project's resources with any of these:.level=trace
org.elasticsearch.client.level=trace
org.elasticsearch.client.RestClient.level=trace
I have also tried different log levels - fine, trace, all.
None of these helped - elasticsearch's logger.isDebugEnabled() method always returns false.
Internally, elasticsearch's RequestLogger has a Jdk14Logger (from commons-logging) and calls its isDebugEnabled() method, which in turn has a java.util.logging.Logger and calls its isLoggable(Level.FINE) method which returns false, since it has no logging level defined.
The key to solving this was removing the
commons-loggingdependency and instead adding a dependency onjcl-over-slf4j.In
sbtthis would look like this:After this, the logger can be configured with
logbackas simply as: