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 JaninoEvantEvaluator
require
Janino
The evaluator examples which are mostly based on
JaninoEvantEvaluator
require Janino
version 2.5.10 or later. Once you downloaded Janino, you need to
place janino.jar on your class path.
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.