svn commit: r2423 - in logback/trunk/logback-site/src/site/pages: . manual

Author: ceki Date: Sat Aug 8 17:28:39 2009 New Revision: 2423 Modified: logback/trunk/logback-site/src/site/pages/index.html logback/trunk/logback-site/src/site/pages/manual/appenders.html logback/trunk/logback-site/src/site/pages/manual/architecture.html logback/trunk/logback-site/src/site/pages/manual/filters.html logback/trunk/logback-site/src/site/pages/manual/introduction.html logback/trunk/logback-site/src/site/pages/manual/jmxConfig.html logback/trunk/logback-site/src/site/pages/manual/layouts.html logback/trunk/logback-site/src/site/pages/manual/loggingSeparation.html logback/trunk/logback-site/src/site/pages/manual/mdc.html logback/trunk/logback-site/src/site/pages/manual/migrationFromLog4j.html logback/trunk/logback-site/src/site/pages/manual/onJoran.html Log: - prettified logback manual pages Modified: logback/trunk/logback-site/src/site/pages/index.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/index.html (original) +++ logback/trunk/logback-site/src/site/pages/index.html Sat Aug 8 17:28:39 2009 @@ -39,7 +39,7 @@ significantly improved version of log4j. Moreover, logback-classic natively implements the <a href="http://www.slf4j.org">SLF4J API</a> so that you can readily switch back and forth between - logback and other logging systems such as log4j or + logback and other logging frameworks such as log4j or java.util.logging (JUL). </p> Modified: logback/trunk/logback-site/src/site/pages/manual/appenders.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/appenders.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/appenders.html Sat Aug 8 17:28:39 2009 @@ -7,10 +7,11 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -46,7 +47,7 @@ interface. The salient methods of this interface are summarized below: </p> - <div class="source"><pre>package ch.qos.logback.core; + <pre class="prettyprint source">package ch.qos.logback.core; import ch.qos.logback.core.spi.ContextAware; import ch.qos.logback.core.spi.FilterAttachable; @@ -61,7 +62,7 @@ public Layout<E> getLayout(); public void setName(String name); -}</pre></div> +}</pre> <p>Most of the methods in the <code>Appender</code> interface are made of setter and getter methods. A notable exception is the @@ -111,7 +112,7 @@ is by presenting an excerpt of actual source code. </p> -<div class="source"><pre>public synchronized void doAppend(E eventObject) { +<pre class="prettyprint source">public synchronized void doAppend(E eventObject) { // prevent re-entry. if (guard) { @@ -139,7 +140,7 @@ } finally { guard = false; } -}</pre></div> +}</pre> <p>This implementation of the <code>doAppend()</code> method is synchronized. It follows that logging to the same appender from @@ -292,7 +293,7 @@ <em>Example 4.<span class="autoEx"/>: Exiting an application without flushing (<a href="../xref/chapter4/ExitWoes1.html">logback-examples/src/main/java/chapter4/ExitWoes1.java</a>)</em> - <p class="source">package chapter4; + <pre class="prettyprint source">package chapter4; import java.io.FileOutputStream; import java.io.OutputStream; @@ -327,7 +328,7 @@ logger.debug("Hello world."); } -}</p> +}</pre> <p>This example creates a <code>WriterAppender</code> that uses an <code>OutputStreamWriter</code> wrapping a @@ -404,7 +405,7 @@ </p> <em>Example 4.<span class="autoEx"/>: ConsoleAppender configuration (logback-examples/src/main/java/chapter4/conf/logback-Console.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <b><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> @@ -416,7 +417,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></p> +</configuration></pre> <p>After you have set your current path to the <em>logback-examples</em> directory, you can give the above @@ -576,7 +577,7 @@ </p> <em>Example 4.<span class="autoEx"/>: FileAppender configuration (logback-examples/src/main/java/chapter4/conf/logback-fileAppender.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <b><appender name="FILE" class="ch.qos.logback.core.FileAppender"> <File>testFile.log</File> @@ -590,7 +591,7 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration></p> +</configuration></pre> <p>After changing the current directory to <em>logback-examples</em>, run this example by launching the @@ -717,7 +718,7 @@ <p>The <code>RollingPolicy</code> interface is presented below:</p> - <p class="source">package ch.qos.logback.core.rolling; + <pre class="prettyprint source">package ch.qos.logback.core.rolling; import ch.qos.logback.core.FileAppender; import ch.qos.logback.core.spi.LifeCycle; @@ -727,7 +728,7 @@ <b>public void rollover() throws RolloverFailure;</b> public String getNewActiveFileName(); public void setParent(FileAppender appender); -}</p> +}</pre> <p>The <code>rollover</code> method proceeds to the file change, renaming or deletion. The <code>getNewActiveFileName()</code> @@ -895,7 +896,7 @@ <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a <code>FixedWindowRollingPolicy</code> (logback-examples/src/main/java/chapter4/conf/logback-RollingFixedWindow.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <b><File>test.log</File></b> @@ -916,7 +917,7 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration></p> +</configuration></pre> <h4> <a name="TimeBasedRollingPolicy" href="#TimeBasedRollingPolicy">TimeBasedRollingPolicy</a> @@ -926,7 +927,12 @@ href="../xref/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.html"> <code>TimeBasedRollingPolicy</code></a> is possibly the most popular rolling policy. It defines a rollover policy based on time, - say by day or by month. + say by day or by month. <code>TimeBasedRollingPolicy</code> is + particular in the sense that it simultaneously implements both the + <code>RollingPolicy</code> as well as the + <code>TriggeringPolicy</code> interfaces. The + <code>TriggeringPolicy</code> interface will be presented in the + next sub-section. </p> <p><code>TimeBasedRollingPolicy</code>'s admits two properties, the @@ -1118,7 +1124,7 @@ <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a <code>TimeBasedRollingPolicy</code> (logback-examples/src/main/java/chapter4/conf/logback-RollingTimeBased.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>logFile.log</File> <b><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> @@ -1135,7 +1141,7 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration></p> +</configuration></pre> <p>The next configuration sample illustrates the use <code>RollingFileAppender</code> associated with @@ -1145,7 +1151,7 @@ <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a <code>TimeBasedRollingPolicy</code> (logback-examples/src/main/java/chapter4/conf/logback-PrudentTimeBasedRolling.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <b><!-- Support multiple-JVM writing to the same log file --></b> <b><Prudent>true</Prudent></b> @@ -1162,24 +1168,61 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration></p> +</configuration></pre> + + + <h3> + <a name="SizeAndTimeBasedFNATP" + href="#SizeAndTimeBasedFNATP">Size <b>and</b> time based archiving</a> + </h3> + <p>You may sometimes wish to archive files essentialy by date but + at the same time limit the size of each log file, in particular if + post-processing tools impose size limits.</p> + <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a + <code>TimeBasedRollingPolicy</code> (logback-examples/src/main/java/chapter4/conf/logback-PrudentTimeBasedRolling.xml)</em> + <pre class="prettyprint source"><configuration> + <appender name="ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <File>${randomOutputDir}z${testId}</File> + <rollingPolicy + class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <FileNamePattern> + ${randomOutputDir}${testId}-%d{yyyy-MM-dd_HH_mm_ss}.%i + </FileNamePattern> + <TimeBasedFileNamingAndTriggeringPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> + <MaxFileSize>${sizeThreshold}</MaxFileSize> + </TimeBasedFileNamingAndTriggeringPolicy> + </rollingPolicy> + <layout> + <Pattern>%msg%n</Pattern> + </layout> + </appender> + <root level="debug"> + <appender-ref ref="ROLLING" /> + </root> + +</configuration></pre> + + + <h3> - <a name="TriggeringPolicy" href="#TriggeringPolicy">Triggering policies</a> + <a name="TriggeringPolicy" href="#TriggeringPolicy">Triggering policy interface</a> </h3> <p><a href="../xref/ch/qos/logback/core/rolling/TriggeringPolicy.html"><code>TriggeringPolicy</code></a> implementations are responsible for instructing the - <code>RollingFileAppender</code> to rollover.</p> + <code>RollingFileAppender</code> when to rollover.</p> <p>The <code>TriggeringPolicy</code> interface contains only one method.</p> - <p class="source">package ch.qos.logback.core.rolling; + <pre class="prettyprint source">package ch.qos.logback.core.rolling; import java.io.File; import ch.qos.logback.core.spi.LifeCycle; @@ -1187,7 +1230,7 @@ public interface TriggeringPolicy<E> extends LifeCycle { <b>public boolean isTriggeringEvent(final File activeFile, final <E> event);</b> -}</p> +}</pre> <p>The <code>isTriggeringEvent()</code> method takes as parameters the active file, and the logging event currently being @@ -1228,7 +1271,7 @@ <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a <code>SizeBasedTriggeringPolicy</code> (logback-examples/src/main/java/chapter4/conf/logback-RollingSizeBased.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>testFile.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> @@ -1248,7 +1291,7 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration></p> +</configuration></pre> <!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx --> @@ -1446,7 +1489,7 @@ </p> <em>Example 4.<span class="autoEx"/>: SocketAppender configuration (logback-examples/src/main/java/chapter4/socket/client1.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="SOCKET" class="ch.qos.logback.classic.net.SocketAppender"> <RemoteHost>${host}</RemoteHost> @@ -1459,7 +1502,7 @@ <appender-ref ref="SOCKET" /> </root> -</configuration></pre></div> +</configuration></pre> <p> @@ -1721,10 +1764,10 @@ naming server one would write: </p> -<div class="source"><pre>Properties env = new Properties(); +<pre class="prettyprint source">Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://<em>hostname</em>:61616"); -Context ctx = new InitialContext(env);</pre></div> +Context ctx = new InitialContext(env);</pre> <p> where <em>hostname</em> is the host where the ActiveMQ server is running. @@ -1792,7 +1835,7 @@ Its most important method, <code>doAppend()</code> is listed below: </p> -<div class="source"><pre>public void append(ILoggingEvent event) { +<pre class="prettyprint source">public void append(ILoggingEvent event) { if (!isStarted()) { return; } @@ -1810,7 +1853,7 @@ } addError("Could not publish message in JMSTopicAppender [" + name + "].", e); } -}</pre></div> +}</pre> <p> The <code>isStarted()</code> method allows the appender to check @@ -1845,7 +1888,7 @@ is implemented as follows: </p> -<div class="source"><pre>public void onMessage(javax.jms.Message message) { +<pre class="prettyprint source">public void onMessage(javax.jms.Message message) { ILoggingEvent event; try { if (message instanceof ObjectMessage) { @@ -1860,7 +1903,7 @@ } catch (JMSException jmse) { logger.error("Exception thrown while processing incoming message.", jmse); } -}</pre></div> +}</pre> <p> The <code>onMessage()</code> method begins by retrieving the logging event's payload. @@ -1906,7 +1949,7 @@ </p> <em>Example 4.<span class="autoEx"/>: JMSTopicAppender configuration (logback-examples/src/main/java/chapter4/conf/logback-JMSTopic.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="Topic" class="ch.qos.logback.classic.net.JMSTopicAppender"> @@ -1923,7 +1966,7 @@ <root level="debug"> <appender-ref ref="Topic" /> </root> -</configuration></pre></div> +</configuration></pre> <a name="JMSQueueAppender"></a> <h3>JMSQueueAppender</h3> @@ -1974,7 +2017,7 @@ similar to that of a <code>JMSTopicAppender</code>. </p> <em>Example 4.<span class="autoEx"/>: JMSQueueAppender configuration (logback-examples/src/main/java/chapter4/conf/logback-JMSQueue.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="Queue" class="ch.qos.logback.classic.net.JMSQueueAppender"> @@ -1991,7 +2034,7 @@ <root level="debug"> <appender-ref ref="Queue" /> </root> -</configuration></pre></div> +</configuration></pre> <h3><a name="SMTPAppender" href="#SMTPAppender">SMTPAppender</a></h3> @@ -2185,7 +2228,7 @@ </p> <em>Example 4.<span class="autoEx"/>: A sample <code>SMTPAppender</code> configuration (logback-examples/src/main/java/chapter4/mail/mail1.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST</SMTPHost> <To>EMAIL-DESTINATION</To> @@ -2200,7 +2243,7 @@ <root level="debug"> <appender-ref ref="EMAIL" /> </root> -</configuration></p> +</configuration></pre> <p>Before trying out <code>chapter4.mail.Email</code> application with the above configuration file, you must set the <span @@ -2227,14 +2270,12 @@ relevant part of <em>mail2.xml</em>. </p> -<div class="source"><pre> - <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> - <SMTPHost>${smtpHost}</SMTPHost> - <To>${to}</To> - <From>${from}</From> - <layout class="ch.qos.logback.classic.html.HTMLLayout"/> - </appender> -</pre></div> + <pre class="prettyprint source"><appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> + <SMTPHost>${smtpHost}</SMTPHost> + <To>${to}</To> + <From>${from}</From> + <layout class="ch.qos.logback.classic.html.HTMLLayout"/> +</appender></pre> <p>You can pass the required parameters on the command line:</p> @@ -2300,7 +2341,7 @@ <em>Example 4.<span class="autoEx"/>: A <code>EventEvaluator</code> implementation that evaluates to <code>true</code> every 1024th event (<a href="../xref/chapter4/mail/CounterBasedEvaluator.html">logback-examples/src/main/java/chapter4/mail/CounterBasedEvaluator.java</a>)</em> -<div class="source"><pre>package chapter4.mail; +<pre class="prettyprint source">package chapter4.mail; import ch.qos.logback.core.boolex.EvaluationException; import ch.qos.logback.core.boolex.EventEvaluator; @@ -2332,7 +2373,7 @@ public void setName(String name) { this.name = name; } -}</pre></div> +}</pre> <p> Note that this implementation extends <code>ContextAwareBase</code> and @@ -2352,7 +2393,7 @@ <em>Example 4.<span class="autoEx"/>: <code>SMTPAppender</code> with custom <code>Evaluator</code> and buffer size (logback-examples/src/main/java/chapter4/mail/mail3.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <b><Evaluator class="chapter4.mail.CounterBasedEvaluator" /></b> <BufferSize>1050</BufferSize> @@ -2365,8 +2406,7 @@ <root level="debug"> <appender-ref ref="EMAIL" /> </root> -</configuration></pre></div> - +</configuration></pre> <h3><a name="smtpAuthentication" @@ -2389,7 +2429,7 @@ <em>Example 4.<span class="autoEx"/>: <code>SMTPAppender</code> to Gmail using SSL (logback-examples/src/main/java/chapter4/mail/gmailSSL.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <b><SMTPHost>smtp.gmail.com</SMTPHost></b> <b><SMTPPort>465</SMTPPort></b> @@ -2409,7 +2449,7 @@ <root level="debug"> <appender-ref ref="EMAIL" /> </root> -</configuration></p> +</configuration></pre> <h3><a name="gmailSTARTTLS" href="#gmailSTARTTLS">SMTPAppender for Gmail @@ -2420,7 +2460,7 @@ <em>Example 4.<span class="autoEx"/>: <code>SMTPAppender</code> to GMAIL using STARTTLS (logback-examples/src/main/java/chapter4/mail/gmailSTARTTLS.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <SMTPHost>smtp.gmail.com</SMTPHost> <SMTPPort>587</SMTPPort> @@ -2440,7 +2480,7 @@ <root level="debug"> <appender-ref ref="EMAIL" /> </root> -</configuration></p> +</configuration></pre> @@ -2736,7 +2776,7 @@ </p> <em>Example 4.<span class="autoEx"/>: <code>DBAppender</code> configuration (logback-examples/src/main/java/chapter4/db/append-toMySQL-with-driverManager.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <b><appender name="DB" class="ch.qos.logback.classic.db.DBAppender"> <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"> @@ -2750,7 +2790,7 @@ <root level="debug" > <appender-ref ref="DB" /> </root> -</configuration></pre></div> +</configuration></pre> <p> The correct driver must be declared. Here, the <code>com.mysql.jdbc.Driver</code> @@ -2786,13 +2826,13 @@ commons-dbcp </a> package from Apache: </p> -<div class="source"><pre> +<pre class="prettyprint source"> <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"> <param name="driver" value="org.apache.commons.dbcp.PoolingDriver"/> <param name="url" value="jdbc:apache:commons:dbcp:/myPoolingDriver"/> </connectionSource> -</pre></div> +</pre> <p> Then the configuration information for the commons-dbcp @@ -2814,7 +2854,7 @@ </p> <em>Example 4.<span class="autoEx"/>: <code>DBAppender</code> configuration (logback-examples/src/main/java/chapter4/db/append-with-datasource.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"> <b><connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource"> @@ -2837,7 +2877,7 @@ <root level="debug"> <appender-ref ref="DB" /> </root> -</configuration></pre></div> +</configuration></pre> <p> Not that in this configuration sample, we make heavy use of substitution variables. @@ -2894,11 +2934,11 @@ application server provides. </p> -<div class="source"><pre><connectionSource class="ch.qos.logback.core.db.JNDIConnectionSource"> +<pre class="prettyprint source"><connectionSource class="ch.qos.logback.core.db.JNDIConnectionSource"> <param name="jndiLocation" value="jdbc/MySQLDS" /> <param name="username" value="myUser" /> <param name="password" value="myPassword" /> -</connectionSource></pre></div> +</connectionSource></pre> <p> Note that this class will obtain an @@ -2927,7 +2967,7 @@ </p> <em>Example 4.<span class="autoEx"/> <code>DBAppender</code> configuration without pooling (logback-examples/src/main/java/chapter4/db/append-toMySQL-with-datasource.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"> <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource"> @@ -2944,7 +2984,7 @@ <root level="debug"> <appender-ref ref="DB" /> </root> -</configuration</p> +</configuration</pre> <p>With this configuration file, sending 500 logging events to a MySQL database takes a whopping 5 seconds, that is 10 milliseconds @@ -2960,7 +3000,7 @@ </p> <em>Example 4.<span class="autoEx"/>: <code>DBAppender</code> configuration with pooling (logback-examples/src/main/java/chapter4/db/append-toMySQL-with-datasource-and-pooling.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"> <connectionSource @@ -2978,7 +3018,7 @@ <root level="debug"> <appender-ref ref="DB" /> </root> -</configuration></p> +</configuration></pre> <p>With this new configuration, sending 500 logging requests to the same MySQL database as previously used takes around 0.5 @@ -3095,7 +3135,7 @@ </p> <em>Example 4.<span class="autoEx"/>: <code>SyslogAppender</code> configuration (logback-examples/src/main/java/chapter4/conf/logback-syslog.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender"> @@ -3107,7 +3147,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>When testing this configuration, you should verify that the remote syslog daemon accepts requests from an external @@ -3155,7 +3195,7 @@ configuration (logback-examples/src/main/java/chapter4/sift/byUserid.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <b><appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"></b> <!-- in the absence of the class attribute, it is assumed that the @@ -3179,7 +3219,7 @@ <root level="DEBUG"> <appender-ref ref="SIFT" /> </root> -</configuration></p> +</configuration></pre> <p>In the absence of a class attribute, it is assumed that the @@ -3239,7 +3279,7 @@ <em>Example 4.<span class="autoExec"/>: <code>CountingConsoleAppender</code> (logback-examples/src/main/java/chapter4/CountingConsoleAppender.java)</em> - <p class="source">package chapter4; + <pre class="prettyprint source">package chapter4; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.Layout; @@ -3284,7 +3324,7 @@ counter++; } -}</p> +}</pre> <p>The <code>start()</code> method checks for the presence of a <code>Layout</code>. In case the layout is not set, the appender @@ -3363,7 +3403,7 @@ Here is a sample configuration of a <code>SMTPAppender</code> in the access environment. </p> <em>Example 4.<span class="autoEx"/>: <code>SMTPAppender</code> configuration (logback-examples/src/main/java/chapter4/conf/access/logback-smtp.xml)</em> -<div class="source"><pre><appender name="SMTP" +<pre class="prettyprint source"><appender name="SMTP" class="ch.qos.logback.access.net.SMTPAppender"> <layout class="ch.qos.logback.access.html.HTMLLayout"> <Pattern>%h%l%u%t%r%s%b</Pattern> @@ -3376,7 +3416,7 @@ <From>sender_email@host.com</From> <SMTPHost>mail.domain.com</SMTPHost> <To>recipient_email@host.com</To> -</appender></pre></div> +</appender></pre> <p> This way of triggering the email lets user select pages that are important steps @@ -3532,7 +3572,7 @@ </p> <em>Example 4.<span class="autoEx"/>: DBAppender configuration (logback-examples/src/main/java/chapter4/conf/access/logback-DB.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="DB" class="ch.qos.logback.access.db.DBAppender"> <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"> @@ -3545,7 +3585,7 @@ </appender> <appender-ref ref="DB" /> -</configuration></p> +</configuration></pre> <h3><a name="AccessSiftingAppender" @@ -3572,7 +3612,7 @@ <em>Example 4.<span class="autoEx"/>: SiftingAppender configuration (logback-examples/src/main/java/chapter4/conf/sift/access-siftingFile.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="SIFTING" class="ch.qos.logback.access.sift.SiftingAppender"> <Discriminator class="ch.qos.logback.access.sift.AccessEventDiscriminator"> <Key>id</Key> @@ -3590,7 +3630,7 @@ </sift> </appender> <appender-ref ref="SIFTING" /> -</configuration></p> +</configuration></pre> <p>In the above configuration file, a <code>SiftingAppender</code> Modified: logback/trunk/logback-site/src/site/pages/manual/architecture.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/architecture.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/architecture.html Sat Aug 8 17:28:39 2009 @@ -8,12 +8,11 @@ <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> - <script type="text/javascript"> - prefix='../'; - </script> + <body onload="prettyPrint()"> + <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -125,8 +124,8 @@ follows: </p> - <p class="source">Logger rootLogger = LoggerFactory.getLogger(<a - href="http://www.slf4j.org/apidocs/constant-values.html#org.slf4j.Logger.ROOT_LOGGER_NAME">org.slf4j.Logger.ROOT_LOGGER_NAME</a>);</p> + <pre class="prettyprint source">Logger rootLogger = LoggerFactory.getLogger(<a + href="http://www.slf4j.org/apidocs/constant-values.html#org.slf4j.Logger.ROOT_LOGGER_NAME">org.slf4j.Logger.ROOT_LOGGER_NAME</a>);</pre> <p>All other loggers are also retrieved with the class static <code>getLogger</code> method found in the <a @@ -136,7 +135,7 @@ interface are listed below. </p> - <p class="source">package org.slf4j; + <pre class="prettyprint source">package org.slf4j; public interface Logger { // Printing methods: @@ -145,7 +144,7 @@ public void info(String message); public void warn(String message); public void error(String message); -}</p> +}</pre> <p>Loggers may be assigned levels. The set of possible levels, that is TRACE, DEBUG, INFO, WARN and ERROR are defined in the @@ -431,7 +430,7 @@ <p>Here is an example of the basic selection rule.</p> - <div class="source"><pre>// get a logger instance named "com.foo" + <pre class="prettyprint source">// get a logger instance named "com.foo" Logger logger = LoggerFactory.getLogger("com.foo"); //set its Level to <span class="blue">INFO</span> logger.setLevel(Level. <span class="blue">INFO</span>); @@ -450,7 +449,7 @@ barlogger.<span class="green bold">info</span>("Located nearest gas station."); // This request is disabled, because <span class="green bold">DEBUG</span> < <span class="blue">INFO</span>. -barlogger.<span class="green bold">debug</span>("Exiting gas station search");</pre></div> +barlogger.<span class="green bold">debug</span>("Exiting gas station search");</pre> <a name="RetrievingLoggers"></a> <h3>Retrieving Loggers</h3> @@ -461,8 +460,8 @@ </p> <p>For example, in</p> - <div class="source"><pre>Logger x = LoggerFactory.getLogger("wombat"); -Logger y = LoggerFactory.getLogger("wombat");</pre></div> + <pre class="prettyprint source">Logger x = LoggerFactory.getLogger("wombat"); +Logger y = LoggerFactory.getLogger("wombat");</pre> <p> <code>x</code> and <code>y</code> refer to @@ -634,7 +633,7 @@ something akin to: </p> - <div class="source"><pre>176 [main] DEBUG chapter2.HelloWorld2 - Hello world.</pre></div> + <div class="prettyprint source"><pre>176 [main] DEBUG chapter2.HelloWorld2 - Hello world.</pre></div> <p>The first field is the number of milliseconds elapsed since the start of the program. The second field is the thread making the @@ -656,7 +655,7 @@ <p>For some Logger <code>logger</code>, writing,</p> - <div class="source"><pre>logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));</pre></div> + <pre class="prettyprint source">logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));</pre> <p>incurs the cost of constructing the message parameter, that is converting both integer <code>i</code> and <code>entry[i]</code> @@ -668,9 +667,9 @@ by surrounding the log statement with a test. Here is an example. </p> - <div class="source"><pre>if(logger.isDebugEnabled()) { + <pre class="prettyprint source">if(logger.isDebugEnabled()) { logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); -}</pre></div> +}</pre> <p>This way you will not incur the cost of parameter construction @@ -690,8 +689,8 @@ </p> - <div class="source"><pre>Object entry = new SomeObject(); -logger.debug("The entry is {}.", entry);</pre></div> + <pre class="prettyprint source">Object entry = new SomeObject(); +logger.debug("The entry is {}.", entry);</pre> <p>After evaluting whether to log or not, and only if the decision is positive, will the logger implementation format the message and @@ -707,15 +706,15 @@ least 30. </p> - <div class="source"><pre>logger.debug("The new entry is "+entry+"."); -logger.debug("The new entry is {}.", entry);</pre></div> + <pre class="prettyprint source">logger.debug("The new entry is "+entry+"."); +logger.debug("The new entry is {}.", entry);</pre> <p>A two argument variant is also availalble. For example, you can write: </p> - <div class="source"><pre>logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);</pre></div> + <pre class="prettyprint source">logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);</pre> <p>If three or more arguments need to be passed, an <code>Object[]</code> variant is also availalble. For example, you @@ -723,8 +722,8 @@ </p> - <div class="source"><pre>Object[] paramArray = {newVal, below, above}; -logger.debug("Value {} was inserted between {} and {}.", paramArray);</pre></div> + <pre class="prettyprint source">Object[] paramArray = {newVal, below, above}; +logger.debug("Value {} was inserted between {} and {}.", paramArray);</pre> <a name="UnderTheHood"></a> @@ -845,7 +844,7 @@ For example, for some logger <em>x</em> writing, </p> - <div class="source"><pre>x.debug("Entry number: " + i + "is " + entry[i]);</pre></div> + <pre class="prettyprint source">x.debug("Entry number: " + i + "is " + entry[i]);</pre> <p> incurs the cost of constructing the message parameter, i.e. converting both @@ -859,7 +858,7 @@ logging: </p> - <div class="source"><pre>x.debug("Entry number: {} is {}", i, entry[i]);</pre></div> + <pre class="prettyprint source">x.debug("Entry number: {} is {}", i, entry[i]);</pre> <p> This variant will not incur the cost of parameter Modified: logback/trunk/logback-site/src/site/pages/manual/filters.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/filters.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/filters.html Sat Aug 8 17:28:39 2009 @@ -8,11 +8,12 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -116,7 +117,7 @@ </p> <em>Example 6.1: Basic custom filter (<a href="../xref/chapter6/SampleFilter.html">logback-examples/src/main/java/chapter6/SampleFilter.java</a>)</em> -<div class="source"><pre>package chapter6; +<pre class="prettyprint source">package chapter6; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.core.filter.Filter; @@ -134,7 +135,7 @@ return FilterReply.NEUTRAL; } } -}</pre></div> +}</pre> <p> What is shown above might be the simplest filter. Like any filter, it @@ -143,7 +144,7 @@ </p> <em>Example 6.2: SampleFilter configuration (logback-examples/src/main/java/chapter6/SampleFilterConfig.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <b><Filter class="chapter6.SampleFilter" /></b> @@ -158,7 +159,7 @@ <root> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>Thanks to Joran, logback's powerful configuration framework, adding an option to such a filter is very easy. Just add the @@ -191,7 +192,7 @@ </p> <em>Example 6.3: Sample LevelFilter configuration (logback-examples/src/main/java/chapter6/levelFilterConfig.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <b><filter class="ch.qos.logback.classic.filter.LevelFilter"> @@ -208,7 +209,7 @@ <root level="DEBUG"> <appender-ref ref="CONSOLE" /> </root> -</configuration></pre></div> +</configuration></pre> <p> The second filter that ships with logback is @@ -220,7 +221,7 @@ </p> <em>Example 6.4: Sample ThresholdFilter configuration (logback-examples/src/main/java/chapter6/thresholdFilterConfig.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <b><filter class="ch.qos.logback.classic.filter.ThresholdFilter"> @@ -235,7 +236,7 @@ <root level="DEBUG"> <appender-ref ref="CONSOLE" /> </root> -</configuration></pre></div> +</configuration></pre> <h3>Evaluator Filters taking Java Expressions</h3> @@ -350,7 +351,7 @@ <em>Example 6.5: Basic event evaluator usage (logback-examples/src/main/java/chapter6/basicEventEvaluator.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> @@ -371,7 +372,7 @@ <root level="INFO"> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>The bold part in the previous configuration adds an <code>EvaluatorFilter</code> to a <code>ConsoleAppender</code>. An @@ -472,7 +473,7 @@ </p> <em>Example 6.6: Basic custom <code>TurboFilter</code> (<a href="../xref/chapter6/SampleTurboFilter.html">logback-examples/src/main/java/chapter6/SampleTurboFilter.java</a>)</em> -<div class="source"><pre>package chapter6; +<pre class="prettyprint source">package chapter6; import org.slf4j.Marker; import org.slf4j.MarkerFactory; @@ -518,7 +519,7 @@ } } } -</pre></div> +</pre> <p>The <code>TurboFilter</code> above accepts events that contain a specific marker. If said marker is not found, then the filter @@ -537,7 +538,7 @@ </p> <em>Example 6.7: Basic custom <code>TurboFilter</code> configuration (logback-examples/src/main/java/chapter6/sampleTurboFilterConfig.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <b><turboFilter class="chapter6.SampleTurboFilter"> <Marker>sample</Marker> </turboFilter></b> @@ -554,7 +555,7 @@ <root> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>Logback classic ships with several <code>TurboFilter</code> classes ready for use. The <a @@ -574,7 +575,7 @@ <em>Example 6.8: <code>MDCFilter</code> and <code>MarkerFilter</code> configuration (logback-examples/src/main/java/chapter6/turboFilters.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <turboFilter class="ch.qos.logback.classic.turbo.MDCFilter"> <MDCKey>username</MDCKey> @@ -596,7 +597,7 @@ <root level="info"> <appender-ref ref="console" /> </root> -</configuration></pre></div> +</configuration></pre> <p>You can see this configuration in action by issuing the following command: @@ -664,8 +665,8 @@ write: </p> - <p class="source">logger.debug("Hello "+name0); -logger.debug("Hello "+name1);</p> + <pre class="prettyprint source">logger.debug("Hello "+name0); +logger.debug("Hello "+name1);</pre> <p>Assuming <code>name0</code> and <code>name1</code> have different values, the two "Hello" messages will be considered as @@ -680,8 +681,8 @@ thus considered as repetitions. </p> - <p class="source">logger.debug("Hello {}.", name0); -logger.debug("Hello {}.", name1);</p> + <pre class="prettyprint source">logger.debug("Hello {}.", name0); +logger.debug("Hello {}.", name1);</pre> <p>The number of allowed repetitions can be specified by the <span class="option">AllowedRepetitions</span> property. For example, if @@ -701,7 +702,7 @@ <em>Example: <code>DuplicateMessageFilter</code> configuration (logback-examples/src/main/java/chapter6/duplicateMessage.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <b><turboFilter class="ch.qos.logback.classic.turbo.DuplicateMessageFilter"/></b> @@ -714,7 +715,7 @@ <root level="info"> <appender-ref ref="console" /> </root> -</configuration></pre></div> +</configuration></pre> <p>Thus, the output for <code>FilterEvents</code> application configured with <em>duplicateMessage.xml</em> is: @@ -775,7 +776,7 @@ </p> <em>Example 6.9: Access Evaluator (logback-examples/src/main/java/chapter6/accessEventEvaluator.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> @@ -794,7 +795,7 @@ </appender> <appender-ref ref="STDOUT" /> -</configuration></pre></div> +</configuration></pre> <p>We might imagine a slightly more complex use of filters to ensure logging of 404 errors, except those returned on access to @@ -802,7 +803,7 @@ </p> <em>Example 6.10: Access Evaluator (logback-examples/src/main/java/chapter6/accessEventEvaluator2.xml)</em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> @@ -829,7 +830,7 @@ <appender-ref ref="STDOUT" /> </configuration> - </p> + </pre> <script src="../templates/footer.js" type="text/javascript"></script> Modified: logback/trunk/logback-site/src/site/pages/manual/introduction.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/introduction.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/introduction.html Sat Aug 8 17:28:39 2009 @@ -7,11 +7,12 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"> </script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -78,7 +79,7 @@ <p>Let us now begin experimenting with logback.</p> <em>Example 1.1: Basic template for logging (<a href="../xref/chapter1/HelloWorld1.html">logback-examples/src/main/java/chapter1/HelloWorld1.java</a>)</em> -<div class="source"><pre>package chapter1; +<pre class="prettyprint source">package chapter1; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -91,7 +92,7 @@ logger.debug("Hello world."); } -}</pre></div> +}</pre> <p><code>HelloWorld</code> class is defined in the <code>chapter1</code> package. It starts by importing the <a @@ -133,7 +134,7 @@ logger. </p> -<div class="source"><pre>20:49:07.962 [main] DEBUG chapter1.HelloWorld1 - Hello world.</pre></div> + <p class="source">20:49:07.962 [main] DEBUG chapter1.HelloWorld1 - Hello world.</p> <p>Logback can report information about its internal state using a built-in status system. Important events occuring during logback's @@ -144,7 +145,7 @@ </p> <em>Example 1.2: Printing Logger Status (<a href="../xref/chapter1/HelloWorld2.html">logback-examples/src/main/java/chapter1/HelloWorld2.java</a>)</em> -<div class="source"><pre>package chapter1; +<pre class="prettyprint source">package chapter1; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -161,7 +162,7 @@ <b>LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc);</b> } -}</pre></div> +}</pre> <p>Running the <code>HelloWorld2</code> application will produce @@ -237,8 +238,9 @@ --> - <p>Logback relies on <a href="http://maven.apache.org">Maven2</a> as - its build tool. Maven2 is a widely-used open-source build tool. + <p>As its build tool, logback relies on <a + href="http://maven.apache.org">Maven2</a>, a widely-used open-source + build tool. </p> <p>Once you have installed Maven2, building the logback project, Modified: logback/trunk/logback-site/src/site/pages/manual/jmxConfig.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/jmxConfig.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/jmxConfig.html Sat Aug 8 17:28:39 2009 @@ -8,11 +8,13 @@ <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" /> <title>JMX Configuration</title> </head> - <body> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -45,9 +47,9 @@ your logback configuration file, as shown below: </p> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <b><jmxConfigurator /></b> - + <appender name="console" class="ch.qos.logback.classic.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%date [%thread] %-5level %logger{25} - %msg%n</Pattern> @@ -57,7 +59,7 @@ <root level="debug"/> <appender-ref ref="console" /> </root> -</configuration></p> +</configuration></pre> <p>After you connect to your server with <em>jconsole</em>, on the MBeans panel, under "ch.qos.logback.classic.jmx.Configurator" @@ -114,7 +116,7 @@ <code>javax.servlet.ServletContextListener</code>. Here is sample code:</p> - <p class="source">import javax.servlet.ServletContextEvent; + <pre class="prettyprint source">import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.slf4j.LoggerFactory; @@ -129,7 +131,7 @@ public void contextInitialized(ServletContextEvent sce) { } -} </p> +} </pre> <!-- ============ Multiple web-applications ================== --> @@ -212,7 +214,7 @@ are the elements that need to be added: </p> - <p class="source"><Call id="MBeanServer" class="java.lang.management.ManagementFactory" + <pre class="prettyprint source"><Call id="MBeanServer" class="java.lang.management.ManagementFactory" name="getPlatformMBeanServer"/> <Get id="Container" name="container"> @@ -224,7 +226,7 @@ </New> </Arg> </Call> -</Get> </p> +</Get> </pre> <p>If you wish to access the MBeans exposed by Jetty via the <code>jconsole</code> application, then you need start jetty after @@ -264,7 +266,7 @@ an instruction to set the management port. </p> - <p class="source"><Call id="MBeanServer" + <pre class="prettyprint source"><Call id="MBeanServer" class="java.lang.management.ManagementFactory" name="getPlatformMBeanServer"/> @@ -279,7 +281,7 @@ </Arg> </Call> </Get> - </p> + </pre> <p>Moreover, <em>mx4j-tools.jar</em> needs to be added to Jetty's class path. @@ -288,7 +290,7 @@ <p>If you are running jetty as a Maven plug-in, then you need to add <em>mx4j-tools</em> as a dependency.</p> - <p class="source"><plugin> + <pre class="prettyprint source"><plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <configuration> @@ -302,7 +304,7 @@ <version>3.0.1</version> </dependency> </dependencies></b> -</plugin></p> +</plugin></pre> <p>After Jetty is started with the above configuration, <code>JMXConfigurator</code> will be available at the following @@ -368,12 +370,12 @@ </p> - <p class="source"><Connector port="0" + <pre class="prettyprint source"><Connector port="0" handler.list="mx" mx.enabled="true" mx.httpHost="localhost" mx.httpPort="8082" - protocol="AJP/1.3" /></p> + protocol="AJP/1.3" /></pre> <p>Once Tomcat is started, you should be able to find JMXConfigurator by pointing your browser at the following URL Modified: logback/trunk/logback-site/src/site/pages/manual/layouts.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/layouts.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/layouts.html Sat Aug 8 17:28:39 2009 @@ -8,11 +8,12 @@ <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> +<body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -49,13 +50,13 @@ interface is shown below. </p> - <div class="source">public interface Layout<E> extends ContextAware, LifeCycle { + <pre class="prettyprint source">public interface Layout<E> extends ContextAware, LifeCycle { String doLayout(E event); String getHeader(); String getFooter(); String getContentType(); -}</div> +}</pre> <p>This interface is rather simple and yet is sufficent for many formatting needs. The Texan developer from Texas, who you might @@ -90,7 +91,7 @@ <a href="../xref/chapter5/MySampleLayout.html"> (logback-examples/src/main/java/chapter5/MySampleLayout.java)</a></em> - <div class="source"><pre>package chapter5; + <pre class="prettyprint source">package chapter5; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.LayoutBase; @@ -111,7 +112,7 @@ sbuf.append(CoreConstants.LINE_SEP); return sbuf.toString(); } -}</pre></div> +}</pre> <p>Note that <code>MySampleLayout</code> extends <a href="../xref/ch/qos/logback/core/LayoutBase.html"> @@ -152,7 +153,7 @@ <em>Example 5.0: Configuration of MySampleLayout (logback-examples/src/main/java/chapter5/sampleLayoutConfig.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> @@ -162,7 +163,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>The sample application <a href="../xref/chapter5/SampleLogging.html"> <code>chapter5.SampleLogging</code></a> configures logback with the @@ -201,7 +202,7 @@ </p> <p>Here is the implementation of this class:</p> - <p class="source">package chapter5; + <pre class="prettyprint source">package chapter5; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.LayoutBase; @@ -240,7 +241,7 @@ sbuf.append(LINE_SEP); return sbuf.toString(); } -}</p> +}</pre> <p>The addition of the corresponding setter method is all that is @@ -253,7 +254,7 @@ </p> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> @@ -266,7 +267,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></p> +</configuration></pre> <p></p> @@ -302,7 +303,7 @@ <a href="../xref/chapter5/PatternSample.html"> (logback-examples/src/main/java/chapter5/PatternSample.java)</a> </em> - <div class="source"><pre>package chapter5; + <pre class="prettyprint source">package chapter5; import org.slf4j.LoggerFactory; @@ -328,7 +329,7 @@ rootLogger.debug("Message 1"); rootLogger.warn("Message 2"); } -}</pre></div> +}</pre> <p>The conversion pattern is set to be <b>"%-5level [%thread]: %message%n"</b>. Running PatternSample will yield the following @@ -1140,13 +1141,13 @@ which will be covered soon, may add evaluator names to the option list, as shown below:</p> - <div class="source"><pre> + <pre class="prettyprint source"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <param name="Pattern" value="%-4relative [%thread] %-5level - %msg%n \ <b>%caller{2, DISP_CALLER_EVAL, OTHER_EVAL_NAME, THIRD_EVAL_NAME}</b>" /> </layout> - </appender></pre></div> + </appender></pre> <h3>Evaluators</h3> @@ -1177,7 +1178,7 @@ Example 5.2: Sample usage of EventEvaluators (logback-examples/src/main/java/chapter5/callerEvaluatorConfig.xml) </em> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <b><evaluator name="DISP_CALLER_EVAL"> <Expression>logger.getName().contains("chapter5") && \ message.contains("who calls thee")</Expression> @@ -1193,7 +1194,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></p> +</configuration></pre> <p>Due to XML encoding rules, the & character cannot be written as is, and needs to be escaped as &.</p> @@ -1207,7 +1208,7 @@ (logback-examples/src/main/java/chapter5/CallerEvaluatorExample.java)</a> </em> </p> - <p class="source">package chapter5; + <pre class="prettyprint source">package chapter5; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1239,7 +1240,7 @@ } } } -}</p> +}</pre> <p> The <em>CallerEvaluatorExample</em> application does nothing particularly fancy. Five logging requests are issued, the third one being @@ -1293,7 +1294,7 @@ (logback-examples/src/main/java/chapter5/ExceptionEvaluatorExample.java)</a> </em> </p> -<div class="source"><pre>package chapter5; +<pre class="prettyprint source">package chapter5; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1325,7 +1326,7 @@ } } } -}</pre></div> +}</pre> <p>The following configuration will supress the stack trace of the third logging request.</p> @@ -1333,7 +1334,7 @@ Example 5.3: Sample usage of EventEvaluators (logback-examples/src/main/java/chapter5/exceptionEvaluatorConfig.xml) </em> - <div class="source"><pre><configuration> + <pre class="prettyprint source"><configuration> <b><evaluator name="DISPLAY_EX_EVAL"> <Expression>throwable != null && throwable instanceof \ @@ -1351,7 +1352,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>With this configuration, each time an instance of the <em>chapter5.TestException</em> is included within a logging @@ -1390,7 +1391,7 @@ <em> Example 5.4: Sample Converter Example <a href="../xref/chapter5/MySampleConverter.html"> (src/main/java/chapter5/MySampleConverter.java)</a></em> -<div class="source"><pre>package chapter5; +<pre class="prettyprint source">package chapter5; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.pattern.ClassicConverter; @@ -1427,7 +1428,7 @@ } } } -</pre></div> +</pre> java chapter5.SampleLogging src/main/java/chapter5/mySampleConverterConfig.xml @@ -1444,7 +1445,7 @@ new conversion word in the configuration file, as shown below:</p> <em> Example 5.4: Sample Converter Example (src/main/java/chapter5/mySampleConverterConfig.xml)</em> -<div class="source"><pre><configuration> +<pre class="prettyprint source"><configuration> <b><conversionRule conversionWord="sample" converterClass="chapter5.MySampleConverter" /></b> @@ -1458,7 +1459,7 @@ <root level="debug"> <appender-ref ref="STDOUT" /> </root> -</configuration></pre></div> +</configuration></pre> <p>In this configuration file, once the new conversion word has been declared, we can refert to it within a @@ -1526,7 +1527,7 @@ the use of <code>HTMLLayout</code>. </p> -<div class="source"><configuration debug="true"> +<pre class="prettyprint source"><configuration debug="true"> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <layout class="ch.qos.logback.classic.html.HTMLLayout"> <b><pattern>%relative%thread%mdc%level%logger%msg</pattern></b> @@ -1538,12 +1539,12 @@ <appender-ref ref="FILE" /> </root> </configuration> -</div> +</pre> <p>Launching the <code>TrivialMain</code> application listed below will create the file <em>test.html</em> on your local drive.</p> - <p class="source">import org.slf4j.Logger; + <pre class="prettyprint source">import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TrivialMain { @@ -1558,7 +1559,7 @@ } logger.error("Finish off with fireworks", new Exception("Just testing")); } -}</p> +}</pre> <p>The contents of <em>test.html</em> should be similar to: </p> @@ -1606,13 +1607,13 @@ <code><layout></code> element, as shown below. </p> -<div class="source"><pre><layout> +<pre class="prettyprint source"><layout> ... <cssBuilder class="ch.qos.logback.core.html.UrlCssBuilder"> <url>path_to_StyleFile.css</url> </cssBuilder> ... -</layout></pre></div> +</layout></pre> <p>The <code>HTMLLayout</code> is often used in conjunction with @@ -1620,7 +1621,7 @@ formatted in HTML. Here is a typical configuration: </p> - <div class="source"><pre><configuration> + <pre class="prettyprint source"><configuration> <appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender"> <layout class="ch.qos.logback.classic.html.HTMLLayout"> <pattern>%relative%thread%mdc%level%class%msg</pattern> @@ -1634,14 +1635,14 @@ <root level="debug"> <appender-ref ref="SMTP" /> </root> -</configuration></pre></div> +</configuration></pre> <p><code>HTMLLayout</code> can also be used with any <code>FileAppender</code>, including a a rolling file appender, as shown in the sample configuration below. </p> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <ActiveFileName>lastLogEntries.html</ActiveFileName> @@ -1660,7 +1661,7 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration></p> +</configuration></pre> <h3><a name="log4jXMLLayout" href="#log4jXMLLayout">Log4j XMLLayout</a></h3> @@ -1690,7 +1691,7 @@ <p>Here is a sample configuration</p> - <p class="source"><configuration> + <pre class="prettyprint source"><configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <File>test.xml</File> <layout class="ch.qos.logback.classic.log4j.XMLLayout"> @@ -1701,7 +1702,7 @@ <root level="debug"> <appender-ref ref="FILE" /> </root> -</configuration> </p> +</configuration> </pre> <h2>Logback access</h2> Modified: logback/trunk/logback-site/src/site/pages/manual/loggingSeparation.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/loggingSeparation.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/loggingSeparation.html Sat Aug 8 17:28:39 2009 @@ -8,10 +8,11 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -91,10 +92,10 @@ referencing a logger is via a static reference. For example, </p> - <p class="source">public class Foo { + <pre class="prettyprint source">public class Foo { <b>static</b> Logger logger = LoggerFactory.getLogger(Foo.class); ... -}</p> +}</pre> <p>Static references are both memory and CPU efficient. Only one logger reference is used for all instances of the class. Moreover, @@ -127,7 +128,7 @@ contexts. When you write: </p> - <p class="source">Logger logger = LoggerFactory.getLogger("foo");</p> + <pre class="prettyprint source">Logger logger = LoggerFactory.getLogger("foo");</pre> <p>the <code>getLogger</code>() method in <code>LoggerFactory</code> class asks the SLF4J binding for a @@ -190,11 +191,11 @@ file. If "kenobi" was the name of your application, you would add the following XML element to kenobi's web.xml file:</p> - <p class="source"><env-entry> + <pre class="prettyprint source"><env-entry> <env-entry-name>logback/context-name</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>kenobi</env-entry-value> -</env-entry></p> +</env-entry></pre> <p>Assuming you have enabled <code>ContextJNDISelector</code>, logging for Kenobi will be done using a logger context named @@ -213,11 +214,11 @@ </p> - <p class="source"><env-entry> + <pre class="prettyprint source"><env-entry> <env-entry-name>logback/configuration-resource</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>my_config.xml</env-entry-value> -</env-entry></p> +</env-entry></pre> <h3>Configuring Tomcat for ContextJNDISelector</h3> @@ -235,7 +236,7 @@ catalina.bat in Windows, found under <em>$TOMCAT_HOME/bin</em> folder.</p> - <p class="source">JAVA_OPTS="$JAVA_OPTS -Dlogback.ContextSelector=JNDI</p> + <p class="source">JAVA_OPTS="$JAVA_OPTS -Dlogback.ContextSelector=JNDI"</p> <h3>Hot deploying applications</h3> @@ -251,9 +252,9 @@ add the following lines to your web-applications <em>web.xml</em> file.</p> - <p class="source"><listener> + <pre class="prettyprint source"><listener> <listener-class>ch.qos.logback.classic.selector.servlet.ContextDetachingSCL</listener-class> -</listener></p> +</listener></pre> <h3>Better performance</h3> @@ -267,14 +268,14 @@ be installed by adding the following lines to your applications web.xml file.</p> - <p class="source"><filter> + <pre class="prettyprint source"><filter> <filter-name>LoggerContextFilter</filter-name> <filter-class>ch.qos.logback.classic.selector.servlet.LoggerContextFilter</filter-class> </filter> <filter-mapping> <filter-name>LoggerContextFilter</filter-name> <url-pattern>/*</url-pattern> -</filter-mapping></p> +</filter-mapping></pre> <p>At the beginning of each http-request, <code>LoggerContextFilter</code> will obtain the logger context Modified: logback/trunk/logback-site/src/site/pages/manual/mdc.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/mdc.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/mdc.html Sat Aug 8 17:28:39 2009 @@ -8,10 +8,11 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../';</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -62,7 +63,7 @@ javadocs</a> for a complete list of methods. </p> -<div class="source"><pre>package org.slf4j; +<pre class="prettyprint source">package org.slf4j; public class MDC { //Put a context value as identified by <em>key</em> @@ -77,7 +78,7 @@ //Clear all entries in the MDC. <b>public static void clear();</b> -}</pre></div> +}</pre> <p>The <code>MDC</code> class contains only static methods. It lets the developer place information in a <em>diagnostic @@ -100,7 +101,7 @@ </p> <em>Example 7.1: Basic MDC usage (<a href="../xref/chapter7/SimpleMDC.html"> logback-examples/src/main/java/chapter7/SimpleMDC.java)</a></em> -<div class="source"><pre>package chapter7; +<pre class="prettyprint source">package chapter7; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -135,7 +136,7 @@ [ SNIP ] -}</pre></div> +}</pre> <p>The main method starts by associating the value <em>Dorothy</em> with the key <em>first</em> in the @@ -150,11 +151,11 @@ relevant section from that file. </p> - <p class="source"><appender name="CONSOLE" - class="ch.qos.logback.core.ConsoleAppender"> <layout - class="ch.qos.logback.classic.PatternLayout"> + <pre class="prettyprint source"><appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> + <layout> <Pattern><b>%X{first} %X{last}</b> - %m%n</Pattern> - </layout> </appender></p> + </layout> +</appender></pre> @@ -215,7 +216,7 @@ <em>Example 7.2: The service interface (<a href="../xref/chapter7/NumberCruncher.html"> logback-examples/src/main/java/chapter7/NumberCruncher.java)</a></em> -<div class="source"><pre>package chapter7; +<pre class="prettyprint source">package chapter7; import java.rmi.Remote; import java.rmi.RemoteException; @@ -229,7 +230,7 @@ * <em>distinct</em> factor's as an integer array. * */ int[] factor(int number) throws RemoteException; -}</pre></div> +}</pre> <p> The <code>NumberCruncherServer</code> application, listed in Example 7.3 below, @@ -239,7 +240,7 @@ <em>Example 7.3: The server side (<a href="../xref/chapter7/NumberCruncherServer.html"> logback-examples/src/main/java/chapter7/NumberCruncherServer.java)</a></em> -<div class="source"><pre>package chapter7; +<pre class="prettyprint source">package chapter7; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; @@ -387,7 +388,7 @@ return; } } -}</pre></div> +}</pre> <p> The implementation of the <code>factor(int number)</code> method is @@ -416,11 +417,9 @@ The <em>mdc1.xml</em> configuration file is listed below: </p> <em>Example 7.4: Configuration file (logback-examples/src/main/java/chapter7/mdc1.xml)</em> -<div class="source"><pre><configuration> - - <appender name="CONSOLE" - class="ch.qos.logback.core.ConsoleAppender"> - <layout class="ch.qos.logback.classic.PatternLayout"> +<pre class="prettyprint source"><configuration> + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> + <layout> <Pattern>%-4r [%thread] %-5level <b>C:%X{client} N:%X{number}</b> - %msg%n</Pattern> </layout> </appender> @@ -428,7 +427,7 @@ <root level="debug"> <appender-ref ref="CONSOLE"/> </root> -</configuration></pre></div> +</configuration></pre> <p> Note the use of the <em>%X</em> conversion specifier within the @@ -532,7 +531,7 @@ <em>Example 7.5: User servlet filter (<a href="../xref/chapter7/UserServletFilter.html"> logback-examples/src/main/java/chapter7/UserServletFilter.java)</a></em> -<div class="source"><pre>package chapter7; +<pre class="prettyprint source">package chapter7; import java.io.IOException; import java.security.Principal; @@ -593,8 +592,7 @@ userRegistered = true; } } -}</pre></div> - +}</pre> <p> When the filter's <code>doFilter()</code> method is called, is first looks for a Modified: logback/trunk/logback-site/src/site/pages/manual/migrationFromLog4j.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/migrationFromLog4j.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/migrationFromLog4j.html Sat Aug 8 17:28:39 2009 @@ -8,10 +8,11 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../'</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -65,7 +66,7 @@ </p> - <p class="source">package chapter11; + <pre class="prettyprint source">package chapter11; import org.apache.log4j.Layout; import org.apache.log4j.spi.LoggingEvent; @@ -83,13 +84,13 @@ public boolean ignoresThrowable() { return true; } -}</p> +}</pre> <p>The logback-classic equivalent named <a href="../xref/chapter11/TrivialLogbackLayout.html">TrivialLogbackLayout</a> would be </p> - <p class="source">package chapter11; + <pre class="prettyprint source">package chapter11; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.LayoutBase; @@ -99,7 +100,7 @@ public String <b>doLayout</b>(ILoggingEvent loggingEvent) { return loggingEvent.getMessage(); } -} </p> +} </pre> <p>As you can see, in a logback-classic layout, the formatting method is named <code>doLayout</code> instead of @@ -133,7 +134,7 @@ href="../xref/chapter11/TrivialLog4jLayout.html">TrivialLog4jLayout</a> which writes on the console the string returned by its layout.</p> - <p class="source">package chapter11; + <pre class="prettyprint source">package chapter11; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.spi.LoggingEvent; @@ -153,14 +154,14 @@ public boolean requiresLayout() { return true; } -}</p> +}</pre> <p>The logback-classic equivalent named <a href="../xref/chapter11/TrivialLogbackAppender.html">TrivialLogbackAppender</a> would be written as</p> - <p class="source">package chapter11; + <pre class="prettyprint source">package chapter11; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; @@ -184,7 +185,7 @@ String s = this.layout.doLayout(loggingevent); System.out.println(s); } -}</p> +}</pre> <p>Comparing the two classes, you should notice that the contents Modified: logback/trunk/logback-site/src/site/pages/manual/onJoran.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/onJoran.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/onJoran.html Sat Aug 8 17:28:39 2009 @@ -8,10 +8,11 @@ <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> + <body onload="prettyPrint()"> <script type="text/javascript">prefix='../'</script> + <script type="text/javascript" src="../js/prettify.js"></script> <script src="../templates/header.js" type="text/javascript"></script> <div id="left"> <noscript>Please turn on Javascript to view this menu</noscript> @@ -162,7 +163,7 @@ </p> - <p class="source">package ch.qos.logback.core.joran.action; + <pre class="prettyprint source">package ch.qos.logback.core.joran.action; import org.xml.sax.Attributes; import ch.qos.logback.core.joran.spi.ExecutionContext; @@ -183,7 +184,7 @@ */ public abstract void end(InterpretationContext ec, String name) throws ActionException; -}</p> +}</pre> <p>Thus, every action must implement the begin and end methods.</p> @@ -302,9 +303,9 @@ (logback-examples/src/main/java/chapter10/calculator/calculator1.xml)</em> <em> </em> - <p class="source"><computation name="total"> + <pre class="prettyprint source"><computation name="total"> <literal value="3"/> -</computation></p> +</computation></pre> <p>In the <a href="../xref/chapter10/calculator/Calculator1.html"> <code>Calculator1</code></a> application, we declare various @@ -383,13 +384,13 @@ <em>Example 10.<span class="autoEx"/>: Calculator configuration file (logback-examples/src/main/java/chapter10/calculator/calculator2.xml)</em> - <div class="source"><pre><computation name="toto"> + <pre class="prettyprint source"><computation name="toto"> <literal value="7"/> <literal value="3"/> <add/> <literal value="3"/> <multiply/> -</computation></pre></div> +</computation></pre> <p>As in the previous example, in response to the <literal> @@ -431,7 +432,7 @@ <em>Example 10.<span class="autoEx"/>: Calculator configuration file (logback-examples/src/main/java/chapter10/calculator/calculator3.xml)</em> -<div class="source"><pre><computation name="toto"> +<pre class="prettyprint source"><computation name="toto"> <computation> <literal value="7"/> <literal value="3"/> @@ -440,7 +441,7 @@ <literal value="3"/> <multiply/> -</computation></pre></div> +</computation></pre> <p>Much like the use of parentheses in an algebrical equation, the presence of a <code>computation</code> element nested in another is @@ -515,7 +516,7 @@ <em>Example 10.<span class="autoEx"/>: Usage of implicit rules (logback-examples/src/main/java/chapter10/implicit/implicit1.xml)</em> - <p class="source"><foo> + <pre class="prettyprint source"><foo> <xyz printme="true"> <abc printme="true"/> </xyz> @@ -524,7 +525,7 @@ <foo printme="true"/> -</foo></p> +</foo></pre> <p>Running</p> @@ -671,8 +672,8 @@ <code>NewRuleCalculator</code>. </p> - <p class="source">ruleMap.put(new Pattern("*/computation"), new ComputationAction1()); -<b>ruleStore.addRule(new Pattern("/computation/new-rule"), new NewRuleAction());</b></p> + <pre class="prettyprint source">ruleMap.put(new Pattern("*/computation"), new ComputationAction1()); +<b>ruleStore.addRule(new Pattern("/computation/new-rule"), new NewRuleAction());</b></pre> <p><a href="../xref/ch/qos/logback/core/joran/action/NewRuleAction.html"><code>NewRuleAction</code></a>, @@ -687,8 +688,8 @@ <p>Here is how new rules can be declared in an xml file:</p> - <p class="source"><new-rule pattern="*/computation/literal" - actionClass="chapter10.calculator.LiteralAction"/></p> + <pre class="prettyprint source"><new-rule pattern="*/computation/literal" + actionClass="chapter10.calculator.LiteralAction"/></pre> <p>Using such new-rule declarations, we can transform <code>NewRuleCalculator</code> to behave like the @@ -699,7 +700,7 @@ rules on the fly (logback-examples/src/main/java/chapter10/newrule/new-rule.xml)</em> - <p class="source"><computation name="toto"> + <pre class="prettyprint source"><computation name="toto"> <new-rule pattern="*/computation/literal" actionClass="chapter10.calculator.LiteralAction"/> <new-rule pattern="*/computation/add" @@ -715,7 +716,7 @@ <literal value="3"/> <multiply/> -</computation></p> +</computation></pre> <p class="command">java java chapter10.newRule.NewRuleCalculator src/main/java/chapter10/newRule/new-rule.xml</p>
participants (1)
-
noreply.ceki@qos.ch