Classpath Setup

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

The logback-*.jar files are part of the logback distribution whereas slf4j-api-2.0.0-alpha5.jar ships with SLF4J, a separate project.

Running from the command line

You can launch the first sample application, chapters.introduction.HelloWord1 with the following command. This assumes that your current directory is $LOGBACK_HOME/logback-examples, where $LOGBACK_HOME stands for the directory where you installed logback:

java -cp lib/slf4j-api-2.0.0-alpha5.jar;../logback-core-1.3.0-alpha13.jar;\ ../logback-classic-1.3.0-alpha13.jar;logback-examples-1.3.0-alpha13.jar\ chapters.introduction.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.

Maven dependency declaration

To use logback-classic in your Maven project, declare the following dependency in your project's pom file.

<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.3.0-alpha13</version>
</dependency>

TRANSITIVITY Note that in addition to logback-classic.jar, the above declaration will automatically pull-in slf4j-api.jar and logback-core.jar into your project by virtue of Maven's transitivity rules.

To include logback-access in your Maven project, declare the following dependency in your project's pom file.

<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-access</artifactId>
  <version>1.3.0-alpha13</version>
</dependency>

Optional dependencies

SMTPAppender requires JavaMail API

SMTPAppender related examples require the JavaMail API version 1.4 or later. Once you download JavaMail, you need to place mail.jar on your class path.

Here is the corresponding Maven dependency declaration for your convenience.

<!-- The javax.activation:activation:1.1 dependency will be -->
<!-- automatically pulled in by Maven's transitivity rules -->
<dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mail</artifactId>
  <version>${javax.mail.version}</version>
</dependency>

Conditional processing and JaninoEventEvaluator require the Janino library

Conditional processing in configuration files requires the Janino library. Moreover, the evaluator examples based on JaninoEventEvaluator require Janino as well. Once you download Janino, simply place commons-compiler.jar and janino.jar on your application's class path.

Don't forget As of Janino version 2.6.0, in addition to janino.jar, commons-compiler.jar needs to be on the class path as well.

Here is the corresponding Maven dependency declaration for your convenience.

<!-- The org.codehaus.janino:commons-compiler:3.1.6 dependency -->
<!-- will be automatically pulled in by Maven's transitivity rules -->
<dependency>
  <groupId>org.codehaus.janino</groupId>
  <artifactId>janino</artifactId>
  <version>3.1.6</version>
</dependency>

Building Logback with an IDE

As of version 1.3.x, logback requires Java 9 to build. However, it can be run on Java 8 or later. Logback version 1.2.x, requried Java 6.x

If you wish to contribute to the project or just hack for fun, you will probably want to import logback as a project into your favorite IDE. Logback uses Maven as its build tool. The only mandatory logback dependency at runrime is the JRE, Also note that building from the command line is fairly trivial, the command 'mvn install' given from $LOGBACK_HOME folder should suffice.

ask for help Notwithstanding the instructions below, if you have trouble building logback from the sources, just ask for help on the logback-dev mailing list.

Building logback with IntelliJ IDEA

Assuming you have the latest version of IntelliJ IDEA installed, no additional plugin installation is necessary. IntelliJ IDEA supports Maven out of the box. You can import logback into IDEA by selecting File→ New Project → Import from external model→ Maven, then select $LOGBACK_HOME as the Root directory. The import should finish successfully in a few seconds.

Building with Eclipse

Building with Eclipse is fairly easy as well. In Eclipse, import the logback project: Import→ Maven→ Existing Maven Projects, select $LOGBACK_HOME folder for the import. The import should finish successfully in a few seconds.