1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Setup</title>
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/_print.css" media="print" />
<link rel="stylesheet" type="text/css" href="css/prettify.css" media="screen" />
</head>
<body onload="prettyPrint(); decorate();">
<script type="text/javascript">prefix=''; </script>
<script type="text/javascript" src="templates/header.js"></script>
<script type="text/javascript" src="js/prettify.js"></script>
<script type="text/javascript" src="js/jquery-min.js"></script>
<script type="text/javascript" src="js/decorator.js"></script>
<div id="left">
<script type="text/javascript" src="templates/left.js"></script>
</div>
<div id="content">
<h2 class="doAnchor">Classpath Setup</h2>
<p>In order to run the examples provided in the documentation, you
need to add the following jars to your class path:
</p>
<ul>
<li>logback-core-1.1.2.jar</li>
<li>logback-classic-1.1.2.jar</li>
<li>logback-examples-1.1.2.jar</li>
<li>slf4j-api-1.7.6.jar</li>
</ul>
<p>The <em>logback-*.jar</em> files are part of the logback
distribution whereas <em>slf4j-api-1.7.6.jar</em> ships
with <a href="http://www.slf4j.org">SLF4J</a>, a separate project.
</p>
<h3 class="doAnchor" name="commandLine">Running from the command
line</h3>
<p>Assuming your current directory is
<em>$LOGBACK_HOME/logback-examples</em>, where
<em>$LOGBACK_HOME</em> stands for the directory where you
installed logback, you can launch the first sample application,
<em>chapters.introduction.HelloWord1</em> with the following command:
</p>
<p class="source">java -cp lib/slf4j-api-1.7.6.jar;../logback-core-1.1.2.jar;\
../logback-classic-1.1.2.jar;logback-examples-1.1.2.jar\
chapters.introduction.HelloWorld1</p>
<p>It is more convenient to set the CLASSPATH environment variable
once and for all before running the examples.
</p>
<p>The <em>setClasspath.cmd</em> script located in the
$LOGBACK_HOME/logback-examples folder will configure the class path
for the MS Windows platform. For Unix, you can use
<em>setClasspath.sh</em>.
</p>
<p>Please edit the script in order to adapt the <em>LB_HOME</em> variable
to match your local environment.</p>
<p>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
<em>$LOGBACK_HOME/logback-examples</em> directory.
</p>
<h3 class="doAnchor" name="SMTP"><code>SMTPAppender</code> requires
JavaMail API</h3>
<p><code>SMTPAppender</code> related examples require the JavaMail
API version 1.4 or later. Once you <a
href="http://java.sun.com/products/javamail/downloads/index.html">download
JavaMail</a>, you need to place <em>mail.jar</em> on your class
path.</p>
<p>Here is the corresponding Maven dependency declaration for your
convenience.</p>
<pre class="prettyprint source"><!-- 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>1.4</version>
</dependency></pre>
<h3 class="doAnchor" name="groovy"><code>GEventEvaluator</code> and
<em>logback.groovy</em> configuration files require the Groovy
runtime</h3>
<p><code>GEventEvaluator</code> depends on the Groovy runtime. It
was tested with Groovy version 2.0.7. Similarly, as the
name indicates <a href="manual/groovy.html">groovy
configuration</a> files require the groovy runtime to be present on
your class path.
</p>
<p>Here is the corresponding Maven dependency declaration for your
convenience.
</p>
<pre class="prettyprint source"><dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.7</version>
</dependency></pre>
<h3 class="doAnchor" name="janino">Conditional processing and
<code>JaninoEventEvaluator</code> require the Janino library</h3>
<p><a href="manual/configuration.html#conditional">Conditional
processing</a> in configuration files requires the <a
href="http://docs.codehaus.org/display/JANINO/Home"><b>Janino
library</b></a>. Moreover, the evaluator examples based on
<code>JaninoEventEvaluator</code> require Janino as well. Once you
download Janino, simply place <em>commons-compiler.jar</em> and
<em>janino.jar</em> on your application's class path.
</p>
<p><span class="label notice">Don't forget</span> As of Janino
version 2.6.0, in addition to <em>janino.jar</em>,
<em>commons-compiler.jar</em> needs to be on the class path as well.</p>
<p>Here is the corresponding Maven dependency declaration for your
convenience.
</p>
<pre class="prettyprint source"><!-- The org.codehaus.janino:commons-compiler:2.6.1 dependency -->
<!-- will be automatically pulled in by Maven's transitivity rules -->
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>2.6.1</version>
</dependency></pre>
<h3 class="doAnchor" name="ide">Building with an IDE</h3>
<p>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. Logback offers
a Groovy-based configurator so there is a dependency on the Groovy
language. It follows that your IDE should have plugins for Maven
and Groovy in order to <em>build</em> logback from your within
IDE. The Groovy dependency just mentioned is a <em>build-time</em>
dependency. The only mandatory logback dependency at runrime is the
JRE, unless of course you wish to use the Groovy configurator in
which case Groovy runtime will be a required dependency as
well. Also note that building from the command line is fairly
trivial, the command 'mvn install' given from $LOGBACK_HOME folder
should suffice. </p>
<p><span class="label">ask for help</span> Notwithstanding the
instructions below, if you have trouble building logback from the
sources, just ask for help on the logback-dev mailing list.</p>
<h3 class="doAnchor" name="idea">Building logback with IntelliJ
IDEA</h3>
<p>Assuming you have the latest version of IntelliJ IDEA installed,
no additional plugin installation is necessary. IntelliJ IDEA
supports Maven as well as Groovy 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.</p>
<h3 class="doAnchor" name="eclipse">Building with Eclipse</h3>
<p>Building logback under Eclipse is a little trickier. Here are
instructions for building logback under Eclipse in 61 easy steps.
</p>
<p>The author does not wish to unduly disparage
<code>m2eclipse</code>. However, as of this writing, that is
October 2011, it appears that the key to building logback under
Eclipse is to avoid using <code>m2eclipse</code>. If you have
<code>m2eclipse</code> installed, you can disable it by removing
the Maven Nature for a given project. In later versions of Eclipse,
m2eclipse is installed bu default. As of logback version 1.0.7, the
<em>pom.xml</em> file for logback-core now deactivates m2eclipse as
explained in <a
href="http://wiki.eclipse.org/M2E_plugin_execution_not_covered#ignore_plugin_goal">M2E
plugin wiki</a>.
</p>
<p>And without further ado here are the steps:
</p>
<ol>
<li>Install Eclipse</li>
<!-- <li>in <em>eclipse.ini</em> file modify the parameter "mx",
i.e. change -Xmx384m to -Xmx1384m</li>
-->
<li>Install the Groovy plugin for Eclipse.
<ul>
<li>
<p>You first need to determine the update site appropriate
for your version of Eclipse. The list of available update
sites is available from <a
href="http://groovy.codehaus.org/Eclipse+Plugin">Groovy
project documentation</a>.
</p>
<p>For example, for Eclipse 4.2 (Juno) the URL of the
update site is
"http://dist.springsource.org/release/GRECLIPSE/e4.2/".
</p>
</li>
<li>In Eclipse, select Help → Intall new Software →
Work with the update site you chose in the previous step and
then Select "Groovy-Eclipse Feature". Installation of other
plugins in particular "m2e Configurator for Groovy-Eclipse"
is <b>not</b> necessary
</li>
</ul>
</li>
<li><pre>cd $LOGBACK_HOME</pre>
where $LOGBACK_HOME stands for the location where you cloned the
logback project from github </li>
<li>In case they exist, remove <em>.settings</em>,
<em>.classpath</em>, <em>.project</em> folders (again if any)
under $LOGBACK_HOME and its sub-folders. Somehow, this step seems
to be crucial.</li>
<li>From the command line, run <code>mvn eclipse:eclipse</code>
in $LOGBACK_HOME</li>
<li>In Eclipse, import the logback project: Import→
General→ Existing Projects into Workspace, select
$LOGBACK_HOME folder for the import
</li>
<li>In Eclipse, remove the
logback-classic/target/generated-sources/groovy-stubs/main
directory from the list of source folders (logback-classic→
project properties → Java Build Path)
</li>
<li>In Eclipse, clean all projects in Eclipse (Project →
Clean)
</li>
<li>In Eclipse, select logback-classic project and convert it to
"Groovy project" (right click on logback-classic project →
Configure → Convert Groovy to Project)
</li>
</ol>
<p>The above listed procedure has been last tested by the author
using Eclipse Juno on April 4th 2013.</p>
<script src="templates/footer.js" type="text/javascript"></script>
</div>
</body>
</html>
|