Replacing log4j with logback

I'd like to replace log4j with logback (so that I can log json messages to
Loggly; see https://github.com/qos-ch/logback-extensions). Elasticsearch
appears to be smart enough to detect what logging libraries are available.
But what are the steps to make this work when using the standalone (.deb)
version? The required logging jars can be copied into
/usr/share/elasticsearch/lib/ and the log4j jar can be deleted, but where
does the logback.xml go?

Hi Eric,

let me list the steps:

  1. Remove log4j jar from $ES_HOME/lib
  2. Copy logback-core and logback-classic jars to $ES_HOME/lib
  3. Add logging facade, ES allows slf4j to override log4j. Copy slf4j-api
    jar to $ES_HOME/lib
  4. Create a new folder that will be added to the ES classpath
    automatically: mkdir $ES_HOME/lib/classes
  5. Put your logback.xml into $ES_HOME/lib/classes
  6. Start ES in the foreground to check the new settings (e.g.
    ./bin/elasticsearch -f)

Best regards

Jörg

On Thursday, July 19, 2012 9:31:51 PM UTC+2, Eric Jain wrote:

I'd like to replace log4j with logback (so that I can log json messages to
Loggly; see GitHub - qos-ch/logback-extensions: The Logback Extensions project provides community supported extensions to the Logback logging framework.). Elasticsearch
appears to be smart enough to detect what logging libraries are available.
But what are the steps to make this work when using the standalone (.deb)
version? The required logging jars can be copied into
/usr/share/elasticsearch/lib/ and the log4j jar can be deleted, but where
does the logback.xml go?

Correction: $ES_HOME/libs/* includes only jars from $ES_HOME/libs, not
subdirectories.

To enable logback configuration, it is possible to start ES with

ES_CLASSPATH="$dir" ./bin/elasticsearch -f

or

ES_JAVA_OPTS="-Dlogback.configurationFile=$dir/logback.xml"
./bin/elasticsearch -f

where $dir is the directory in which logback.xml is present.

Best regards,

Jörg

On Friday, July 20, 2012 12:28:52 AM UTC+2, Jörg Prante wrote:

Hi Eric,

let me list the steps:

  1. Remove log4j jar from $ES_HOME/lib
  2. Copy logback-core and logback-classic jars to $ES_HOME/lib
  3. Add logging facade, ES allows slf4j to override log4j. Copy slf4j-api
    jar to $ES_HOME/lib
  4. Create a new folder that will be added to the ES classpath
    automatically: mkdir $ES_HOME/lib/classes
  5. Put your logback.xml into $ES_HOME/lib/classes
  6. Start ES in the foreground to check the new settings (e.g.
    ./bin/elasticsearch -f)

Best regards

Jörg

On Thursday, July 19, 2012 9:31:51 PM UTC+2, Eric Jain wrote:

I'd like to replace log4j with logback (so that I can log json messages
to Loggly; see GitHub - qos-ch/logback-extensions: The Logback Extensions project provides community supported extensions to the Logback logging framework.).
Elasticsearch appears to be smart enough to detect what logging libraries
are available. But what are the steps to make this work when using the
standalone (.deb) version? The required logging jars can be copied into
/usr/share/elasticsearch/lib/ and the log4j jar can be deleted, but where
does the logback.xml go?

On Sat, Jul 21, 2012 at 1:49 AM, Jörg Prante joergprante@gmail.com wrote:

ES_JAVA_OPTS="-Dlogback.configurationFile=$dir/logback.xml"

Thanks, this works!