Classpath Setup

In order to run the examples provided in the documentation, you need to add the following jars to your class path:

Running from the command line

Assuming your current directory is $LOGBACK_HOME/logback-examples, where $LOGBACK_HOME stands for the directory where you installed logback, you can launch the first sample application, chapter1.HelloWord1 with the following command:

java -cp
 lib/slf4j-api-${slf4j.version}.jar;../logback-core-${version}.jar;\
 ../logback-classic-${version}.jar;logback-examples-${version}.jar\
 chapter1.HelloWorld1

It is more convenient to set the CLASSPATH environment variable once and for all before running the examples.

The setClasspath.cmd script located in the $LOGBACK_HOME/logback-examples folder will configure the class path for the MS Windows platform. For Unix, you can use setClasspath.sh.

Please edit the script in order to adapt the LB_HOME variable to match your local environment.

Please be aware that many examples will launch java classes along with configuration files. To access these files by using the same commands as written in the documentation, you will need to issue the commands from within the $LOGBACK_HOME/logback-examples directory.

Using an IDE, e.g. Eclipse

You can import the logback project into Eclipse. Since logback uses maven as its build system, the "maven eclipse:eclipse" command will create the .classpath and .project files for Eclipse. You can then import the logback project into Eclipse in one or two clicks.