Classpath Setup
In order to run the examples provided in the documentation, you need to add the following jars to your class path:
- logback-core-${version}.jar
- logback-classic-${version}.jar
- logback-examples-${version}.jar
- slf4j-api-${slf4j.version}.jar
The logback-*.jar files are part of the logback distribution whereas slf4j-api-${slf4j.version}.jar ships with SLF4J, a separate project.
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, chapters.introduction.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\ 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.
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.
GEventEvaluator
requires the
Groovy runtime
GEventEvaluator
depends on the Groovy runtime. It
was tested with Groovy version 1.7.2.
Evaluators and more
specifically JaninoEventEvaluator
require
Janino
The evaluator examples which are mostly based on
JaninoEventEvaluator
require Janino
version 2.5.10 or later. Once you have downloaded Janino, you need to
place janino.jar on your class path.
Building with an IDE, e.g. IntelliJ IDEA
Certain logback test cases are written in Scala. Moreover, logback offers a Groovy-based configurator. If you wish to hack logback, you will probably want to import it as a project into your favorite IDE. As of this writing (2011-10-26), the author was unable to have the project build under Eclipse due to problems related to Scala and/or Groovy support. Fortunately, assuming the Scala plugin is installed, logback can be imported into IntelliJ IDEA within seconds and built just fine.
If you are able to install both Scala and Groovy under Eclipse, and thus presumably build logback under Eclipse, please report your extraordinary technical feat on the logback-dev mailing list.