[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-62-gde8338d
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Thu Mar 4 16:19:37 CET 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via de8338dedace96fe8abb83a9a932a7abed31d0f3 (commit)
from 3d5ba2cfc7f4c381ba2fc10cd0a5342c6330757c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=de8338dedace96fe8abb83a9a932a7abed31d0f3
http://github.com/ceki/logback/commit/de8338dedace96fe8abb83a9a932a7abed31d0f3
commit de8338dedace96fe8abb83a9a932a7abed31d0f3
Author: Ceki Gulcu <ceki at qos.ch>
Date: Thu Mar 4 16:18:55 2010 +0100
- chapter renumbering in the manual
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
index 95ad0d2..cbe3b90 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
@@ -56,7 +56,7 @@ public class ResilientFileOutputStream extends OutputStream {
return file;
}
- boolean isPresumedInError() {
+ final private boolean isPresumedInError() {
// existence of recoveryCoordinator indicates failed state
return (recoveryCoordinator != null && !presumedClean);
}
@@ -93,7 +93,7 @@ public class ResilientFileOutputStream extends OutputStream {
}
}
- private void postSuccessfulWrite() {
+ final private void postSuccessfulWrite() {
if (recoveryCoordinator != null) {
recoveryCoordinator = null;
statusCount = 0;
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
index bda5873..342de5d 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
@@ -7,7 +7,7 @@
<configuration>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
- <Evaluator class="chapter4.mail.CounterBasedEvaluator" />
+ <Evaluator class="chapters.appenders.mail.CounterBasedEvaluator" />
<BufferSize>1050</BufferSize>
<SMTPHost>${smtpHost}</SMTPHost>
<To>${to}</To>
diff --git a/logback-examples/src/main/java/chapters/architecture/sample-config-3.xml b/logback-examples/src/main/java/chapters/architecture/sample-config-3.xml
index ae279c9..e486c21 100644
--- a/logback-examples/src/main/java/chapters/architecture/sample-config-3.xml
+++ b/logback-examples/src/main/java/chapters/architecture/sample-config-3.xml
@@ -17,7 +17,7 @@
<File>sample-log.txt</File>
</appender>
- <logger name="chapter2" level="info" />
+ <logger name="chapters.architecture" level="info" />
<root level="debug">
<appender-ref ref="STDOUT" />
diff --git a/logback-examples/src/main/java/chapters/configuration/containingConfig.xml b/logback-examples/src/main/java/chapters/configuration/containingConfig.xml
index a6bc77b..b9693e5 100644
--- a/logback-examples/src/main/java/chapters/configuration/containingConfig.xml
+++ b/logback-examples/src/main/java/chapters/configuration/containingConfig.xml
@@ -2,7 +2,7 @@
<configuration>
- <include file="src/main/java/chapter3/includedConfig.xml" />
+ <include file="src/main/java/chapters/configuration/includedConfig.xml" />
<root level="DEBUG">
<appender-ref ref="includedConsole" />
diff --git a/logback-examples/src/main/java/chapters/configuration/variableSubstitution3.xml b/logback-examples/src/main/java/chapters/configuration/variableSubstitution3.xml
index 10d9643..3a5e0a4 100644
--- a/logback-examples/src/main/java/chapters/configuration/variableSubstitution3.xml
+++ b/logback-examples/src/main/java/chapters/configuration/variableSubstitution3.xml
@@ -1,6 +1,6 @@
<configuration>
- <property file="src/main/java/chapter3/variables1.properties" />
+ <property file="src/main/java/chapters/configuration/variables1.properties" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${USER_HOME}/myApp.log</file>
diff --git a/logback-examples/src/main/java/chapters/configuration/variableSubstitution4.xml b/logback-examples/src/main/java/chapters/configuration/variableSubstitution4.xml
index 361eb57..a35ada7 100644
--- a/logback-examples/src/main/java/chapters/configuration/variableSubstitution4.xml
+++ b/logback-examples/src/main/java/chapters/configuration/variableSubstitution4.xml
@@ -1,6 +1,6 @@
<configuration>
- <property file="src/main/java/chapter3/variables2.properties" />
+ <property file="src/main/java/chapters/configuration/variables2.properties" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${destination}/myApp.log</file>
diff --git a/logback-examples/src/main/java/chapters/filters/sampleFilterConfig.xml b/logback-examples/src/main/java/chapters/filters/sampleFilterConfig.xml
index 1e8a10e..203b247 100644
--- a/logback-examples/src/main/java/chapters/filters/sampleFilterConfig.xml
+++ b/logback-examples/src/main/java/chapters/filters/sampleFilterConfig.xml
@@ -2,7 +2,7 @@
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
- <Filter class="chapter6.SampleFilter" />
+ <Filter class="chapters.filters.SampleFilter" />
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
diff --git a/logback-examples/src/main/java/chapters/filters/sampleTurboFilterConfig.xml b/logback-examples/src/main/java/chapters/filters/sampleTurboFilterConfig.xml
index 6421d5f..cb9dbe3 100644
--- a/logback-examples/src/main/java/chapters/filters/sampleTurboFilterConfig.xml
+++ b/logback-examples/src/main/java/chapters/filters/sampleTurboFilterConfig.xml
@@ -1,6 +1,6 @@
<configuration>
- <turboFilter class="chapter6.SampleTurboFilter">
+ <turboFilter class="chapters.filters.SampleTurboFilter">
<Marker>sample</Marker>
</turboFilter>
diff --git a/logback-examples/src/main/java/chapters/layouts/callerEvaluatorConfig.xml b/logback-examples/src/main/java/chapters/layouts/callerEvaluatorConfig.xml
index 1d84e19..ffbcb38 100644
--- a/logback-examples/src/main/java/chapters/layouts/callerEvaluatorConfig.xml
+++ b/logback-examples/src/main/java/chapters/layouts/callerEvaluatorConfig.xml
@@ -2,7 +2,7 @@
<evaluator name="DISPLAY_CALLER_EVAL">
<Expression>
- logger.getName().contains("chapter5") && message.contains("who calls thee")
+ logger.getName().contains("chapters.layouts") && message.contains("who calls thee")
</Expression>
</evaluator>
diff --git a/logback-examples/src/main/java/chapters/layouts/exceptionEvaluatorConfig.xml b/logback-examples/src/main/java/chapters/layouts/exceptionEvaluatorConfig.xml
index f9b8502..1f51577 100644
--- a/logback-examples/src/main/java/chapters/layouts/exceptionEvaluatorConfig.xml
+++ b/logback-examples/src/main/java/chapters/layouts/exceptionEvaluatorConfig.xml
@@ -1,7 +1,7 @@
<configuration>
<evaluator name="DISPLAY_EX_EVAL">
- <Expression>throwable != null && throwable instanceof chapter5.TestException</Expression>
+ <Expression>throwable != null && throwable instanceof chapters.layouts.TestException</Expression>
</evaluator>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
diff --git a/logback-examples/src/main/java/chapters/layouts/mySampleConverterConfig.xml b/logback-examples/src/main/java/chapters/layouts/mySampleConverterConfig.xml
index c526c1b..048eb24 100644
--- a/logback-examples/src/main/java/chapters/layouts/mySampleConverterConfig.xml
+++ b/logback-examples/src/main/java/chapters/layouts/mySampleConverterConfig.xml
@@ -1,6 +1,6 @@
<configuration>
- <conversionRule conversionWord="sample" converterClass="chapter5.MySampleConverter" />
+ <conversionRule conversionWord="sample" converterClass="chapters.layouts.MySampleConverter" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
diff --git a/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig.xml b/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig.xml
index 4ec1933..9cff3bb 100644
--- a/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig.xml
+++ b/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig.xml
@@ -2,7 +2,7 @@
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
- <layout class="chapter5.MySampleLayout" />
+ <layout class="chapters.layouts.MySampleLayout" />
</appender>
<root level="debug">
diff --git a/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig2.xml b/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig2.xml
index 24ed95d..5c302fb 100644
--- a/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig2.xml
+++ b/logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig2.xml
@@ -2,7 +2,7 @@
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
- <layout class="chapter5.MySampleLayout2">
+ <layout class="chapters.layouts.MySampleLayout2">
<prefix>MyPrefix</prefix>
<printThreadName>false</printThreadName>
</layout>
diff --git a/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java b/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java
index 5c58943..142964d 100644
--- a/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java
+++ b/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java
@@ -42,7 +42,7 @@ public class NumberCruncherClient {
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java chapter7.NumberCruncherClient HOST\n" +
+ System.err.println("Usage: java chapters.mdc.NumberCruncherClient HOST\n" +
" where HOST is the machine where the NumberCruncherServer is running.");
System.exit(1);
}
diff --git a/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java b/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java
index 47fa237..cadb377 100644
--- a/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java
+++ b/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java
@@ -113,7 +113,7 @@ public class NumberCruncherServer extends UnicastRemoteObject
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java chapter7.NumberCruncherServer configFile\n" +
+ System.err.println("Usage: java chapters.mdc.NumberCruncherServer configFile\n" +
" where configFile is a logback configuration file.");
System.exit(1);
}
diff --git a/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java b/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java
index a2fa7ae..927de27 100644
--- a/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java
+++ b/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java
@@ -34,7 +34,7 @@ public class SimpleMDC {
// we put the first name
MDC.put("first", "Dorothy");
- // configure via the configuration file "chapter7/simpleMDC.xml"
+ // configure via the configuration file "chapters/mdc/simpleMDC.xml"
// which ships with the examples
configureViaXML_File();
@@ -84,7 +84,7 @@ public class SimpleMDC {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.stop();
- URL url = Loader.getResourceBySelfClassLoader("chapter7/simpleMDC.xml");
+ URL url = Loader.getResourceBySelfClassLoader("chapters/mdc/simpleMDC.xml");
configurator.doConfigure(url);
} catch (JoranException je) {
StatusPrinter.print(lc);
diff --git a/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java b/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java
index 5feed3f..cc9db4c 100644
--- a/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java
+++ b/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java
@@ -40,7 +40,7 @@ import org.slf4j.MDC;
* <filter>
* <filter-name>User Servlet Filter</filter-name>
* <filter-class>
- * chapter7.UserServletFilter
+ * chapters.mdc.UserServletFilter
* </filter-class>
* </filter>
* <filter-mapping>
diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java
index 281fd6e..f61f54a 100644
--- a/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java
+++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java
@@ -27,7 +27,7 @@ public class Log4jMain {
static Logger logger = Logger.getLogger(Log4jMain.class);
public static void main(String[] args) {
- PropertyConfigurator.configure("src/main/java/chapter11/log4jTrivial.properties");
+ PropertyConfigurator.configure("src/main/java/chapters/migrationFromLog4j/log4jTrivial.properties");
logger.debug("Hello world");
}
diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java
index feb8532..76fff92 100644
--- a/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java
+++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java
@@ -38,7 +38,7 @@ public class LogbackMain {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
- configurator.doConfigure("src/main/java/chapter11/logback-trivial.xml");
+ configurator.doConfigure("src/main/java/chapters/migrationFromLog4j/logback-trivial.xml");
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/log4jTrivial.properties b/logback-examples/src/main/java/chapters/migrationFromLog4j/log4jTrivial.properties
index db27c8b..74017ed 100644
--- a/logback-examples/src/main/java/chapters/migrationFromLog4j/log4jTrivial.properties
+++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/log4jTrivial.properties
@@ -1,3 +1,3 @@
log4j.rootLogger=DEBUG, TRIVIAL
-log4j.appender.TRIVIAL=chapter11.TrivialLog4jAppender
-log4j.appender.TRIVIAL.layout=chapter11.TrivialLog4jLayout
\ No newline at end of file
+log4j.appender.TRIVIAL=chapters.migrationFromLog4j.TrivialLog4jAppender
+log4j.appender.TRIVIAL.layout=chapters.migrationFromLog4j.TrivialLog4jLayout
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/logback-trivial.xml b/logback-examples/src/main/java/chapters/migrationFromLog4j/logback-trivial.xml
index 1423887..9c23d9a 100644
--- a/logback-examples/src/main/java/chapters/migrationFromLog4j/logback-trivial.xml
+++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/logback-trivial.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
- <appender name="TRIVIAL" class="chapter11.TrivialLogbackAppender">
- <layout class="chapter11.TrivialLogbackLayout"/>
+ <appender name="TRIVIAL" class="chapters.migrationFromLog4j.TrivialLogbackAppender">
+ <layout class="chapters.migrationFromLog4j.TrivialLogbackLayout"/>
</appender>
<root level="DEBUG">
<appender-ref ref="TRIVIAL"/>
diff --git a/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java b/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java
new file mode 100644
index 0000000..27e434d
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java
@@ -0,0 +1,64 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran;
+
+import java.util.List;
+import java.util.Map;
+
+import ch.qos.logback.core.joran.GenericConfigurator;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.ImplicitAction;
+import ch.qos.logback.core.joran.spi.Interpreter;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.joran.spi.RuleStore;
+
+/**
+ * A minimal configurator extending GenericConfigurator.
+ *
+ * @author Ceki Gücü
+ *
+ */
+public class SimpleConfigurator extends GenericConfigurator {
+
+ final Map<Pattern, Action> ruleMap;
+ final List<ImplicitAction> iaList;
+
+ public SimpleConfigurator(Map<Pattern, Action> ruleMap) {
+ this(ruleMap, null);
+ }
+
+ public SimpleConfigurator(Map<Pattern, Action> ruleMap, List<ImplicitAction> iaList) {
+ this.ruleMap = ruleMap;
+ this.iaList = iaList;
+ }
+
+ @Override
+ protected void addInstanceRules(RuleStore rs) {
+ for (Pattern pattern : ruleMap.keySet()) {
+ Action action = ruleMap.get(pattern);
+ rs.addRule(pattern, action);
+ }
+ }
+
+ @Override
+ protected void addImplicitRules(Interpreter interpreter) {
+ if(iaList == null) {
+ return;
+ }
+ for (ImplicitAction ia : iaList) {
+ interpreter.addImplicitAction(ia);
+ }
+ }
+
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java b/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java
new file mode 100644
index 0000000..c58f6f5
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java
@@ -0,0 +1,69 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+import java.util.EmptyStackException;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+
+
+/**
+ * This action adds the two integers at the top of the stack (they are removed)
+ * and pushes the result to the top the stack.
+ *
+ * @author Ceki Gülcü
+ */
+public class AddAction extends Action {
+
+ public void begin(InterpretationContext ic, String name, Attributes attributes) {
+ int first = fetchInteger(ic);
+ int second = fetchInteger(ic);
+ // Push the result of the addition for the following actions.
+ ic.pushObject(new Integer(first + second));
+ }
+
+ /**
+ * Pop the Integer object at the top of the stack.
+ * This code also illustrates usage of Joran's error handling paradigm.
+ */
+ int fetchInteger(InterpretationContext ic) {
+ int result = 0;
+
+ try {
+ // Pop the object at the top of the interpretation context's stack.
+ Object o1 = ic.popObject();
+
+ if (o1 instanceof Integer) {
+ result = ((Integer) o1).intValue();
+ } else {
+ String errMsg =
+ "Object [" + o1
+ + "] currently at the top of the stack is not an integer.";
+ ic.addError(errMsg);
+ throw new IllegalArgumentException(errMsg);
+ }
+ } catch (EmptyStackException ese) {
+ ic.addError(("Expecting an integer on the execution stack."));
+ throw ese;
+ }
+ return result;
+ }
+
+ public void end(InterpretationContext ic, String name) {
+ // Nothing to do here.
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java
new file mode 100644
index 0000000..e3444cf
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java
@@ -0,0 +1,55 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.StatusPrinter;
+import chapters.onJoran.SimpleConfigurator;
+
+/**
+ * This examples illustrates collaboration between multiple actions through the
+ * common execution context stack.
+ *
+ * @author Ceki Güulcü
+ */
+public class Calculator1 {
+
+ public static void main(String[] args) throws Exception {
+ Context context = new ContextBase();
+
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
+ // Associate "/computation" pattern with ComputationAction1
+ ruleMap.put(new Pattern("/computation"), new ComputationAction1());
+
+ // Other associations
+ ruleMap.put(new Pattern("/computation/literal"), new LiteralAction());
+ ruleMap.put(new Pattern("/computation/add"), new AddAction());
+ ruleMap.put(new Pattern("/computation/multiply"), new MultiplyAction());
+
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ simpleConfigurator.doConfigure(args[0]);
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java
new file mode 100644
index 0000000..1a637ce
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java
@@ -0,0 +1,64 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.StatusPrinter;
+import chapters.onJoran.SimpleConfigurator;
+
+
+/**
+ * This examples illustrates collaboration between multiple actions through the
+ * common execution context stack.
+ *
+ * It differs from Calculator1 in that it supports arbitrary nesting of
+ * computation elements.
+ *
+ * You can test this application with the sample XML file <em>calculator3.xml</em>.
+ *
+ * @author Ceki Güulcü
+ */
+public class Calculator2 {
+ public static void main(String[] args) throws Exception {
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
+
+ // Note the wild card character '*', in the paterns, signifying any level
+ // of nesting.
+ ruleMap.put(new Pattern("*/computation"), new ComputationAction2());
+
+ ruleMap.put(new Pattern("*/computation/literal"), new LiteralAction());
+ ruleMap.put(new Pattern("*/computation/add"), new AddAction());
+ ruleMap.put(new Pattern("*/computation/multiply"), new MultiplyAction());
+
+ Context context = new ContextBase();
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ try {
+ simpleConfigurator.doConfigure(args[0]);
+ } catch (JoranException e) {
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java
new file mode 100644
index 0000000..a71c652
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java
@@ -0,0 +1,61 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+import ch.qos.logback.core.util.OptionHelper;
+
+
+/**
+ * ComputationAction1 will print the result of the compuration made by
+ * children elements but only if the compuration itself is named, that is if the
+ * name attribute of the associated computation element is not null. In other
+ * words, anonymous computations will not print their result.
+ *
+ * @author Ceki Gülcü
+ */
+public class ComputationAction1 extends Action {
+ public static String NAME_ATR = "name";
+
+ String nameStr;
+
+ /**
+ * Store the value of the name attribute for future use.
+ */
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
+ nameStr = attributes.getValue(NAME_ATR);
+ }
+
+ /**
+ * Children elements have been processed. The sesults should be an integer
+ * placed at the top of the execution stack.
+ *
+ * This value will be printed on the console but only if the action is
+ * named. Anonymous computation will not print their result.
+ */
+ public void end(InterpretationContext ec, String name) {
+ if (OptionHelper.isEmpty(nameStr)) {
+ // nothing to do
+ } else {
+ Integer i = (Integer) ec.peekObject();
+ System.out.println(
+ "The computation named [" + nameStr + "] resulted in the value " + i);
+ }
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java
new file mode 100644
index 0000000..ed32c45
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java
@@ -0,0 +1,86 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+import java.util.Stack;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+import ch.qos.logback.core.util.OptionHelper;
+
+
+/**
+ * ComputationAction2 will print the result of the compuration made by
+ * children elements but only if the computation itself is named, that is if the
+ * name attribute of the associated computation element is not null. In other
+ * words, anonymous computations will not print their result.
+ *
+ * ComputationAction2 differs from ComputationAction1 in its handling of
+ * instance variables. ComputationAction1 has a simple <Code>nameStr</code>
+ * instance variable. This variable is set when the begin() method is called
+ * and then later used within the end() method.
+ *
+ * This simple approach works properly if the begin() and end()
+ * method of a given action are expected to be called in sequence. However,
+ * there are situations where the begin() method of the same action instance is
+ * invoked multiple times before the matching end() method is invoked.
+ *
+ * When this happens, the second call to begin() overwrites values set by
+ * the first invocation to begin(). The solution is to save parameter values
+ * into a separate stack. The well-formedness of XML will guarantee that a value
+ * saved by one begin() will be consumed only by the matching end() method.
+ *
+ * Note that in the vast majority of cases there is no need to resort to a
+ * separate stack for each variable. The situation of successive begin()
+ * invocations can only occur if:
+ *
+ * 1) the associated pattern contains a wildcard, i.e. the * character
+ *
+ * and
+ *
+ * 2) the associated element tag can contain itself as a child
+ *
+ * For example, "*/computation" pattern means that computations can contain
+ * other computation elements as children.
+ *
+ * @author Ceki Gülcü
+ */
+public class ComputationAction2 extends Action {
+ public static String NAME_ATR = "name";
+
+ Stack<String> nameStrStack = new Stack<String>();
+
+
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
+ String nameStr = attributes.getValue(NAME_ATR);
+ // save nameStr value in a special stack. Note that the value is saved
+ // even if it is empty or null.
+ nameStrStack.push(nameStr);
+ }
+
+ public void end(InterpretationContext ec, String name) {
+ // pop nameStr value from the special stack
+ String nameStr = (String) nameStrStack.pop();
+
+ if (OptionHelper.isEmpty(nameStr)) {
+ // nothing to do
+ } else {
+ Integer i = (Integer) ec.peekObject();
+ System.out.println(
+ "The computation named [" + nameStr + "] resulted in the value " + i);
+ }
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java b/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java
new file mode 100644
index 0000000..d56c3a4
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java
@@ -0,0 +1,58 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+import ch.qos.logback.core.util.OptionHelper;
+
+/**
+ * This action converts the value attribute of the associated element to an
+ * integer and pushes the resulting Integer object on top of the execution
+ * context stack.
+ *
+ * <p>It also illustrates usage of Joran's error reporting/handling paradigm.
+ *
+ * @author Ceki Gülcü
+ */
+public class LiteralAction extends Action {
+ public static String VALUE_ATR = "value";
+
+ public void begin(InterpretationContext ic, String name, Attributes attributes) {
+ String valueStr = attributes.getValue(VALUE_ATR);
+
+ if (OptionHelper.isEmpty(valueStr)) {
+ ic.addError("The literal action requires a value attribute");
+ return;
+ }
+
+ try {
+ Integer i = Integer.valueOf(valueStr);
+ ic.pushObject(i);
+ } catch (NumberFormatException nfe) {
+ ic.addError("The value [" + valueStr
+ + "] could not be converted to an Integer", nfe);
+ throw nfe;
+ }
+ }
+
+ public void end(InterpretationContext ic, String name) {
+ // Nothing to do here.
+ // In general, the end() method of actions associated with elements
+ // having no children do not need to perform any processing in their
+ // end() method.
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java b/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java
new file mode 100644
index 0000000..2b2ae95
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java
@@ -0,0 +1,66 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.calculator;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+
+import java.util.EmptyStackException;
+
+/**
+ *
+ * This action multiplies the two integers at the top of the stack (they are
+ * removed) and pushes the result on top the stack.
+ *
+ * @author Ceki Gülcü
+ */
+public class MultiplyAction extends Action {
+
+ public void begin(InterpretationContext ic, String name, Attributes attributes) {
+ int first = fetchInteger(ic);
+ int second = fetchInteger(ic);
+ ic.pushObject(new Integer(first * second));
+ }
+
+ /**
+ * Pop the Integer object at the top of the stack. This code illustrates usage
+ * of Joran's error handling paradigm.
+ */
+ int fetchInteger(InterpretationContext ic) {
+ int result = 0;
+
+ try {
+ Object o1 = ic.popObject();
+
+ if (o1 instanceof Integer) {
+ result = ((Integer) o1).intValue();
+ } else {
+ String errMsg = "Object [" + o1
+ + "] currently at the top of the stack is not an integer.";
+ ic.addError(errMsg);
+ throw new IllegalArgumentException(errMsg);
+ }
+ } catch (EmptyStackException ese) {
+ ic.addError("Expecting an integer on the execution stack.");
+ throw ese;
+ }
+ return result;
+ }
+
+ public void end(InterpretationContext ic, String name) {
+ // Nothing to do here.
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/calculator1.xml b/logback-examples/src/main/java/chapters/onJoran/calculator/calculator1.xml
new file mode 100644
index 0000000..111db47
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/calculator1.xml
@@ -0,0 +1,3 @@
+<computation name="total">
+ <literal value="3"/>
+</computation>
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/calculator2.xml b/logback-examples/src/main/java/chapters/onJoran/calculator/calculator2.xml
new file mode 100644
index 0000000..4a96c62
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/calculator2.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE computation>
+
+<computation name="toto">
+ <literal value="7"/>
+ <literal value="3"/>
+ <add/>
+ <literal value="3"/>
+ <multiply/>
+</computation>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/calculator3.xml b/logback-examples/src/main/java/chapters/onJoran/calculator/calculator3.xml
new file mode 100644
index 0000000..837c513
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/calculator3.xml
@@ -0,0 +1,15 @@
+<!-- This file is intended to be executed by Caculator2.
+ It is not suited for Calculator1 due to nested computation
+ elements.
+ -->
+
+<computation name="toto">
+ <computation>
+ <literal value="7"/>
+ <literal value="3"/>
+ <add/>
+ </computation>
+
+ <literal value="3"/>
+ <multiply/>
+</computation>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/readme.txt b/logback-examples/src/main/java/chapters/onJoran/calculator/readme.txt
new file mode 100644
index 0000000..a0d9621
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/calculator/readme.txt
@@ -0,0 +1,7 @@
+This directory contains the the calculator example. It shows how Actions can
+collaborate in order to accomplish a simple computation.
+
+For further information, please refer to
+
+ http://logback.qos.ch/manual/onJoran.html#calculator
+
diff --git a/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java
new file mode 100644
index 0000000..6b9f3e5
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java
@@ -0,0 +1,48 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.helloWorld;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.StatusPrinter;
+import chapters.onJoran.SimpleConfigurator;
+
+/**
+ *
+ * A hello world example using Joran.
+ *
+ * @author Ceki Gulcu
+ */
+public class HelloWorld {
+ public static void main(String[] args) throws Exception {
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
+ // Associate "hello-world" pattern with HelloWorldAction
+ ruleMap.put(new Pattern("hello-world"), new HelloWorldAction());
+
+ // Joran needs to work within a context.
+ Context context = new ContextBase();
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ simpleConfigurator.doConfigure(args[0]);
+ StatusPrinter.print(context);
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java
new file mode 100644
index 0000000..aecc201
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java
@@ -0,0 +1,35 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.helloWorld;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+
+/**
+ * A trivial action that writes "Hello world" on the console.
+ *
+ * See the {@link HelloWorld} class for integration with Joran.
+ *
+ * @author Ceki Gülcü
+ */
+public class HelloWorldAction extends Action {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
+ System.out.println("Hello World");
+ }
+
+ public void end(InterpretationContext ec, String name) {
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/helloWorld/hello.xml b/logback-examples/src/main/java/chapters/onJoran/helloWorld/hello.xml
new file mode 100644
index 0000000..7d764cd
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/helloWorld/hello.xml
@@ -0,0 +1,2 @@
+<hello-world>
+</hello-world>
diff --git a/logback-examples/src/main/java/chapters/onJoran/helloWorld/readme.txt b/logback-examples/src/main/java/chapters/onJoran/helloWorld/readme.txt
new file mode 100644
index 0000000..c96bb14
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/helloWorld/readme.txt
@@ -0,0 +1,6 @@
+The example illustrates the minimal plumbing required for using Joran.
+
+For further explanations, please refer to
+
+ http://logback.qos.ch/manual/onJoran.html#helloWorld
+
diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java b/logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java
similarity index 54%
copy from logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java
copy to logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java
index 281fd6e..ce8c0db 100644
--- a/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java
+++ b/logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java
@@ -11,24 +11,24 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package chapters.migrationFromLog4j;
+package chapters.onJoran.implicit;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
/**
- * A minimal application making use of log4j and TrivialLog4jAppender.
- *
+ * No operation (NOP) action that does strictly nothing.
+ *
* @author Ceki Gülcü
- *
*/
-public class Log4jMain {
-
- static Logger logger = Logger.getLogger(Log4jMain.class);
-
- public static void main(String[] args) {
- PropertyConfigurator.configure("src/main/java/chapter11/log4jTrivial.properties");
- logger.debug("Hello world");
+public class NOPAction extends Action {
+
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
+ public void end(InterpretationContext ec, String name) {
+ }
}
diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java
new file mode 100644
index 0000000..3e007a8
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java
@@ -0,0 +1,61 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.implicit;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.ImplicitAction;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.StatusPrinter;
+import chapters.onJoran.SimpleConfigurator;
+
+/**
+ * This example illustrates the usage of implicit actions.
+ *
+ * <p>Keep in mind that implicit actions are not associated with any specific
+ * pattern. Moreover, they are added directly to a Joran Interpreter instead of
+ * a rule store.
+ *
+ * @author Ceki Güulcü
+ */
+public class PrintMe {
+
+ public static void main(String[] args) throws Exception {
+ Context context = new ContextBase();
+
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
+ // we start with the rule for the top-most (root) element
+ ruleMap.put(new Pattern("*/foo"), new NOPAction());
+
+ // Add an implicit action.
+ List<ImplicitAction> iaList = new ArrayList<ImplicitAction>();
+ iaList.add(new PrintMeImplicitAction());
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap,
+ iaList);
+
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ simpleConfigurator.doConfigure(args[0]);
+ StatusPrinter.printInCaseOfErrorsOrWarnings(context);
+
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java
new file mode 100644
index 0000000..e708619
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java
@@ -0,0 +1,44 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.implicit;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.ImplicitAction;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+import ch.qos.logback.core.joran.spi.Pattern;
+
+/**
+ *
+ * A rather trivial implicit action which is applicable if an element has a
+ * printme attribute set to true.
+ *
+ * @author Ceki Gülcü
+ */
+public class PrintMeImplicitAction extends ImplicitAction {
+
+ public boolean isApplicable(Pattern pattern, Attributes attributes,
+ InterpretationContext ec) {
+ String printmeStr = attributes.getValue("printme");
+
+ return Boolean.valueOf(printmeStr).booleanValue();
+ }
+
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
+ System.out.println("Element [" + name + "] asked to be printed.");
+ }
+
+ public void end(InterpretationContext ec, String name) {
+ }
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/implicit1.xml b/logback-examples/src/main/java/chapters/onJoran/implicit/implicit1.xml
new file mode 100644
index 0000000..54fe4d9
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/implicit/implicit1.xml
@@ -0,0 +1,21 @@
+<foo>
+
+ <!-- These elements will print due to the implicit rule -->
+ <xyz printme="true">
+ <abc printme="true"/>
+ </xyz>
+
+ <!-- This element has no associated rule and no implicit rule
+ applies for it because the printme attribute is not set. -->
+ <xyz/>
+
+
+
+ <!-- This element will not be printed even if its printme
+ attribute is set because implicit rules are invoked only
+ if no explicit rule matches the element. The */foo rule
+ matches the following element.
+ -->
+ <foo printme="true"/>
+
+</foo>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/readme.txt b/logback-examples/src/main/java/chapters/onJoran/implicit/readme.txt
new file mode 100644
index 0000000..ad5fc94
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/implicit/readme.txt
@@ -0,0 +1,7 @@
+
+This directory contains an example illustrating implicit actions.
+
+For further information, please refer to
+
+ http://logback.qos.ch/manual/onJoran.html#implicit
+
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java b/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java
new file mode 100644
index 0000000..7585155
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java
@@ -0,0 +1,63 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.onJoran.newRule;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.NewRuleAction;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.StatusPrinter;
+import chapters.onJoran.SimpleConfigurator;
+import chapters.onJoran.calculator.ComputationAction1;
+
+/**
+ * This example illustrates the usage of NewRuleAction which allows the Joran
+ * interpreter to learn new rules on the fly.
+ *
+ * <p>This example relies heavily on the code from the joran.calculator
+ * package.
+ *
+ * @author Ceki Güulcü
+ */
+public class NewRuleCalculator {
+ public static void main(String[] args) throws Exception {
+
+ Context context = new ContextBase();
+
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
+ // we start with the rule for the top-most (root) element
+ ruleMap.put(new Pattern("*/computation"), new ComputationAction1());
+
+ // Associate "/new-rule" pattern with NewRuleAction from the
+ // org.apache.joran.action package.
+ //
+ // We will let the XML file to teach the Joran interpreter about new rules
+ ruleMap.put(new Pattern("/computation/new-rule"), new NewRuleAction());
+
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ simpleConfigurator.doConfigure(args[0]);
+
+ // Print any errors that might have occured.
+ StatusPrinter.printInCaseOfErrorsOrWarnings(context);
+ }
+
+}
diff --git a/logback-examples/src/main/java/chapters/onJoran/newRule/new-rule.xml b/logback-examples/src/main/java/chapters/onJoran/newRule/new-rule.xml
new file mode 100644
index 0000000..8416bc4
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/newRule/new-rule.xml
@@ -0,0 +1,23 @@
+<!--
+ This file is intended to be executed by NewRuleCalculator.
+ Note that the rules for adding and multiplying are learned on
+ the fly, while parsingthis file.
+-->
+
+<computation name="toto">
+ <new-rule pattern="*/computation/literal"
+ actionClass="chapters.onJoran.calculator.LiteralAction"/>
+ <new-rule pattern="*/computation/add"
+ actionClass="chapters.onJoran.calculator.AddAction"/>
+ <new-rule pattern="*/computation/multiply"
+ actionClass="chapters.onJoran.calculator.MultiplyAction"/>
+
+ <computation>
+ <literal value="7"/>
+ <literal value="3"/>
+ <add/>
+ </computation>
+
+ <literal value="3"/>
+ <multiply/>
+</computation>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/onJoran/newRule/readme.txt b/logback-examples/src/main/java/chapters/onJoran/newRule/readme.txt
new file mode 100644
index 0000000..fb7a5ca
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/onJoran/newRule/readme.txt
@@ -0,0 +1,8 @@
+
+This directory contains an example showing how Joran can
+learn new parsing rules on the fly.
+
+For further documentation please see
+
+ http://logback.qos.ch/manual/onJoran.html#newRule
+
diff --git a/logback-site/src/site/pages/faq.html b/logback-site/src/site/pages/faq.html
index de18525..d5ab5b9 100644
--- a/logback-site/src/site/pages/faq.html
+++ b/logback-site/src/site/pages/faq.html
@@ -322,7 +322,7 @@
place the file <em>logback.xml</em> under the
<em>$JETTY_HOME/resources</em> directory. You can find
sample configuration files in the
- <em>logback-examples/src/main/java/chapter4/conf/</em>
+ <em>logback-examples/src/main/java/chapters/appenders/conf/</em>
folder shipping within the logback distribution.
</p>
diff --git a/logback-site/src/site/pages/index.html b/logback-site/src/site/pages/index.html
index 495c196..f9942ce 100644
--- a/logback-site/src/site/pages/index.html
+++ b/logback-site/src/site/pages/index.html
@@ -62,6 +62,8 @@
<li><a href="http://www.jfrog.org/products.php">Artifactory</a></li>
+ <li><a href="http://www.geomajas.org/">Geomajas</a></li>
+
<li><a href="http://code.google.com/p/openmeetings/">OpenMeetings</a></li>
<li><a href="http://liftweb.net/">Lift</a></li>
@@ -72,8 +74,8 @@
<li><a
href="http://static.springsource.org/s2-dmserver/2.0.x/user-guide/htmlsingle/user-guide.html">SpringSource
dm Server</a></li>
-
+ </ul>
<script src="templates/footer.js" type="text/javascript"></script>
</div>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index f36f1d3..2469859 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -3363,7 +3363,7 @@ logger.debug("Alice says hello"); </p>
<em>Example 4.<span class="autoExec"/>:
<code>CountingConsoleAppender</code>
(logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java)</em>
- <pre class="prettyprint source">package chapter4;
+ <pre class="prettyprint source">package chapters.appenders;
import ch.qos.logback.core.AppenderBase;
import ch.qos.logback.core.Layout;
diff --git a/logback-site/src/site/pages/manual/filters.html b/logback-site/src/site/pages/manual/filters.html
index 46a2f68..716c3f2 100644
--- a/logback-site/src/site/pages/manual/filters.html
+++ b/logback-site/src/site/pages/manual/filters.html
@@ -105,8 +105,8 @@
events, the value NEUTRAL is returned.
</p>
-<em>Example 6.<span class="autoEx"/>: Basic custom filter (<a href="../xref/chapter6/SampleFilter.html">logback-examples/src/main/java/chapter6/SampleFilter.java</a>)</em>
-<pre class="prettyprint source">package chapter6;
+<em>Example 6.<span class="autoEx"/>: Basic custom filter (<a href="../xref/chapters/filters/SampleFilter.html">logback-examples/src/main/java/chapters/filters/SampleFilter.java</a>)</em>
+<pre class="prettyprint source">package chapters.filters;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
@@ -128,11 +128,11 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<code>SampleFilter</code> to a <code>ConsoleAppener</code>.
</p>
-<em>Example 6.<span class="autoEx"/>: SampleFilter configuration (logback-examples/src/main/java/chapter6/SampleFilterConfig.xml)</em>
+<em>Example 6.<span class="autoEx"/>: SampleFilter configuration (logback-examples/src/main/java/chapters/filters/SampleFilterConfig.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <b><Filter class="chapter6.SampleFilter" /></b>
+ <b><Filter class="chapters.filters.SampleFilter" /></b>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
@@ -183,7 +183,7 @@ public class SampleFilter extends Filter>ILoggingEvent> {
configuration file.
</p>
-<em>Example 6.<span class="autoEx"/>: Sample LevelFilter configuration (logback-examples/src/main/java/chapter6/levelFilterConfig.xml)</em>
+<em>Example 6.<span class="autoEx"/>: Sample LevelFilter configuration (logback-examples/src/main/java/chapters/filters/levelFilterConfig.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
@@ -215,7 +215,7 @@ public class SampleFilter extends Filter>ILoggingEvent> {
configuration file.
</p>
-<em>Example 6.<span class="autoEx"/>: Sample ThresholdFilter configuration (logback-examples/src/main/java/chapter6/thresholdFilterConfig.xml)</em>
+<em>Example 6.<span class="autoEx"/>: Sample ThresholdFilter configuration (logback-examples/src/main/java/chapters/filters/thresholdFilterConfig.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
@@ -393,7 +393,7 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<p>Here is a concrete example.</p>
-<em>Example 6.<span class="autoEx"/>: Basic event evaluator usage (logback-examples/src/main/java/chapter6/basicEventEvaluator.xml)</em>
+<em>Example 6.<span class="autoEx"/>: Basic event evaluator usage (logback-examples/src/main/java/chapters/filters/basicEventEvaluator.xml)</em>
<pre class="prettyprint source longline"><configuration>
@@ -444,27 +444,27 @@ public class SampleFilter extends Filter>ILoggingEvent> {
</p>
<p>The <a
- href="../xref/chapter6/FilterEvents.html"><code>FilterEvents</code></a>
+ href="../xref/chapters/filters/FilterEvents.html"><code>FilterEvents</code></a>
application issues ten logging requests, numbered 0 to 9. Let us
first run <code>FilterEvents</code> class without any filters:
</p>
<div class="source"><pre>
-java chapter6.FilterEvents src/main/java/chapter6/basicConfiguration.xml
+java chapters.filters.FilterEvents src/main/java/chapters/filters/basicConfiguration.xml
</pre></div>
<p>All requests will be displayed, as shown below:</p>
-<div class="source"><pre>0 [main] INFO chapter6.FilterEvents - logging statement 0
-0 [main] INFO chapter6.FilterEvents - logging statement 1
-0 [main] INFO chapter6.FilterEvents - logging statement 2
-0 [main] DEBUG chapter6.FilterEvents - logging statement 3
-0 [main] INFO chapter6.FilterEvents - logging statement 4
-0 [main] INFO chapter6.FilterEvents - logging statement 5
-0 [main] ERROR chapter6.FilterEvents - <b>billing statement 6</b>
-0 [main] INFO chapter6.FilterEvents - logging statement 7
-0 [main] INFO chapter6.FilterEvents - logging statement 8
-0 [main] INFO chapter6.FilterEvents - logging statement 9</pre></div>
+<div class="source"><pre>0 [main] INFO chapters.filters.FilterEvents - logging statement 0
+0 [main] INFO chapters.filters.FilterEvents - logging statement 1
+0 [main] INFO chapters.filters.FilterEvents - logging statement 2
+0 [main] DEBUG chapters.filters.FilterEvents - logging statement 3
+0 [main] INFO chapters.filters.FilterEvents - logging statement 4
+0 [main] INFO chapters.filters.FilterEvents - logging statement 5
+0 [main] ERROR chapters.filters.FilterEvents - <b>billing statement 6</b>
+0 [main] INFO chapters.filters.FilterEvents - logging statement 7
+0 [main] INFO chapters.filters.FilterEvents - logging statement 8
+0 [main] INFO chapters.filters.FilterEvents - logging statement 9</pre></div>
@@ -474,19 +474,19 @@ java chapter6.FilterEvents src/main/java/chapter6/basicConfiguration.xml
precisely the desired outcome.</p>
<p>Running with <em>basicEventEvaluator.xml</em>:</p>
- <p class="source">java chapter6.FilterEvents src/main/java/chapter6/basicEventEvaluator.xml</p>
+ <p class="source">java chapters.filters.FilterEvents src/main/java/chapters/filters/basicEventEvaluator.xml</p>
<p>we obtain:
</p>
- <p class="source">0 [main] INFO chapter6.FilterEvents - logging statement 0
-0 [main] INFO chapter6.FilterEvents - logging statement 1
-0 [main] INFO chapter6.FilterEvents - logging statement 2
-0 [main] DEBUG chapter6.FilterEvents - logging statement 3
-0 [main] INFO chapter6.FilterEvents - logging statement 4
-0 [main] INFO chapter6.FilterEvents - logging statement 5
-0 [main] INFO chapter6.FilterEvents - logging statement 7
-0 [main] INFO chapter6.FilterEvents - logging statement 8
-0 [main] INFO chapter6.FilterEvents - logging statement 9</p>
+ <p class="source">0 [main] INFO chapters.filters.FilterEvents - logging statement 0
+0 [main] INFO chapters.filters.FilterEvents - logging statement 1
+0 [main] INFO chapters.filters.FilterEvents - logging statement 2
+0 [main] DEBUG chapters.filters.FilterEvents - logging statement 3
+0 [main] INFO chapters.filters.FilterEvents - logging statement 4
+0 [main] INFO chapters.filters.FilterEvents - logging statement 5
+0 [main] INFO chapters.filters.FilterEvents - logging statement 7
+0 [main] INFO chapters.filters.FilterEvents - logging statement 8
+0 [main] INFO chapters.filters.FilterEvents - logging statement 9</p>
<h2><a name="matcher" href="#matcher">Matchers</a></h2>
@@ -502,7 +502,7 @@ java chapter6.FilterEvents src/main/java/chapter6/basicConfiguration.xml
<p>An example should clarify the point:</p>
-<em>Example 6.<span class="autoEx"/>: Defining matchers in an event evaluator (logback-examples/src/main/java/chapter6/evaluatorWithMatcher.xml)</em>
+<em>Example 6.<span class="autoEx"/>: Defining matchers in an event evaluator (logback-examples/src/main/java/chapters/filters/evaluatorWithMatcher.xml)</em>
<pre class="prettyprint source"><configuration debug="true">
@@ -531,15 +531,15 @@ java chapter6.FilterEvents src/main/java/chapter6/basicConfiguration.xml
</configuration></pre>
<p>Running with <em>evaluatorWithMatcher.xml</em>:</p>
- <p class="source">java chapter6.FilterEvents src/main/java/chapter6/evaluatorWithMatcher.xml</p>
+ <p class="source">java chapters.filters.FilterEvents src/main/java/chapters/filters/evaluatorWithMatcher.xml</p>
<p>we obtain:
</p>
- <p class="source">260 [main] INFO chapter6.FilterEvents - logging statement 0
-264 [main] INFO chapter6.FilterEvents - logging statement 2
-264 [main] INFO chapter6.FilterEvents - logging statement 4
-266 [main] ERROR chapter6.FilterEvents - billing statement 6
-266 [main] INFO chapter6.FilterEvents - logging statement 8</p>
+ <p class="source">260 [main] INFO chapters.filters.FilterEvents - logging statement 0
+264 [main] INFO chapters.filters.FilterEvents - logging statement 2
+264 [main] INFO chapters.filters.FilterEvents - logging statement 4
+266 [main] ERROR chapters.filters.FilterEvents - billing statement 6
+266 [main] INFO chapters.filters.FilterEvents - logging statement 8</p>
<p>In case you need to define additional matchers, you can do so by
adding further <code><matcher></code> elements.</p>
@@ -587,8 +587,8 @@ java chapter6.FilterEvents src/main/java/chapter6/basicConfiguration.xml
slightly more complex filter:
</p>
-<em>Example 6.<span class="autoEx"/>: Basic custom <code>TurboFilter</code> (<a href="../xref/chapter6/SampleTurboFilter.html">logback-examples/src/main/java/chapter6/SampleTurboFilter.java</a>)</em>
-<pre class="prettyprint source">package chapter6;
+<em>Example 6.<span class="autoEx"/>: Basic custom <code>TurboFilter</code> (<a href="../xref/chapters/filters/SampleTurboFilter.html">logback-examples/src/main/java/chapters/filters/SampleTurboFilter.java</a>)</em>
+<pre class="prettyprint source">package chapters.filters;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
@@ -652,9 +652,9 @@ public class SampleTurboFilter extends TurboFilter {
created <code>TurboFilter</code>.
</p>
-<em>Example 6.<span class="autoEx"/>: Basic custom <code>TurboFilter</code> configuration (logback-examples/src/main/java/chapter6/sampleTurboFilterConfig.xml)</em>
+<em>Example 6.<span class="autoEx"/>: Basic custom <code>TurboFilter</code> configuration (logback-examples/src/main/java/chapters/filters/sampleTurboFilterConfig.xml)</em>
<pre class="prettyprint source"><configuration>
- <b><turboFilter class="chapter6.SampleTurboFilter">
+ <b><turboFilter class="chapters.filters.SampleTurboFilter">
<Marker>sample</Marker>
</turboFilter></b>
@@ -689,7 +689,7 @@ public class SampleTurboFilter extends TurboFilter {
</p>
<em>Example 6.<span class="autoEx"/>: <code>MDCFilter</code> and <code>MarkerFilter</code>
-configuration (logback-examples/src/main/java/chapter6/turboFilters.xml)</em>
+configuration (logback-examples/src/main/java/chapters/filters/turboFilters.xml)</em>
<pre class="prettyprint source"><configuration>
<turboFilter class="ch.qos.logback.classic.turbo.MDCFilter">
@@ -718,10 +718,10 @@ configuration (logback-examples/src/main/java/chapter6/turboFilters.xml)</em>
following command:
</p>
- <p class="source">java chapter6.FilterEvents src/main/java/chapter6/turboFilters.xml</p>
+ <p class="source">java chapters.filters.FilterEvents src/main/java/chapters/filters/turboFilters.xml</p>
<p>As we've seen previously, the <a
- href="../xref/chapter6/FilterEvents.html"><code>FilterEvents</code></a>
+ href="../xref/chapters/filters/FilterEvents.html"><code>FilterEvents</code></a>
application issues 10 logging requests, numbered 0 to 9. Except
for requests 3 and 6, all of the requests are of level
<em>INFO</em>, the same level as the one assigned to the root
@@ -739,15 +739,15 @@ configuration (logback-examples/src/main/java/chapter6/turboFilters.xml)</em>
configured with <em>turboFilters.xml</em> file shown above is:
</p>
- <p class="source">2006-12-04 15:17:22,859 [main] INFO chapter6.FilterEvents - logging statement 0
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 1
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 2
-2006-12-04 15:17:22,875 [main] DEBUG chapter6.FilterEvents - logging statement 3
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 4
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 5
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 7
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 8
-2006-12-04 15:17:22,875 [main] INFO chapter6.FilterEvents - logging statement 9</p>
+ <p class="source">2006-12-04 15:17:22,859 [main] INFO chapters.filters.FilterEvents - logging statement 0
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 1
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 2
+2006-12-04 15:17:22,875 [main] DEBUG chapters.filters.FilterEvents - logging statement 3
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 4
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 5
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 7
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 8
+2006-12-04 15:17:22,875 [main] INFO chapters.filters.FilterEvents - logging statement 9</p>
<p>One can see that the 3rd request, which should not be displayed
@@ -816,7 +816,7 @@ logger.debug("Hello {}.", name1);</pre>
<em>Example 6.<span class="autoEx"/>: <code>DuplicateMessageFilter</code>
-configuration (logback-examples/src/main/java/chapter6/duplicateMessage.xml)</em>
+configuration (logback-examples/src/main/java/chapters/filters/duplicateMessage.xml)</em>
<pre class="prettyprint source"><configuration>
<b><turboFilter class="ch.qos.logback.classic.turbo.DuplicateMessageFilter"/></b>
@@ -836,12 +836,12 @@ configuration (logback-examples/src/main/java/chapter6/duplicateMessage.xml)</em
configured with <em>duplicateMessage.xml</em> is:
</p>
- <p class="source">2008-12-19 15:04:26,156 [main] INFO chapter6.FilterEvents - logging statement 0
-2008-12-19 15:04:26,156 [main] INFO chapter6.FilterEvents - logging statement 1
-2008-12-19 15:04:26,156 [main] INFO chapter6.FilterEvents - logging statement 2
-2008-12-19 15:04:26,156 [main] INFO chapter6.FilterEvents - logging statement 4
-2008-12-19 15:04:26,156 [main] INFO chapter6.FilterEvents - logging statement 5
-2008-12-19 15:04:26,171 [main] ERROR chapter6.FilterEvents - billing statement 6</p>
+ <p class="source">2008-12-19 15:04:26,156 [main] INFO chapters.filters.FilterEvents - logging statement 0
+2008-12-19 15:04:26,156 [main] INFO chapters.filters.FilterEvents - logging statement 1
+2008-12-19 15:04:26,156 [main] INFO chapters.filters.FilterEvents - logging statement 2
+2008-12-19 15:04:26,156 [main] INFO chapters.filters.FilterEvents - logging statement 4
+2008-12-19 15:04:26,156 [main] INFO chapters.filters.FilterEvents - logging statement 5
+2008-12-19 15:04:26,171 [main] ERROR chapters.filters.FilterEvents - billing statement 6</p>
<p>"logging statement 0" is the first <em>occurrence</em> of the
message "logging statement {}". "logging statement 1" is the first
@@ -890,7 +890,7 @@ configuration (logback-examples/src/main/java/chapter6/duplicateMessage.xml)</em
error will be logged:
</p>
-<em>Example 6.<span class="autoEx"/>: Access Evaluator (logback-examples/src/main/java/chapter6/accessEventEvaluator.xml)</em>
+<em>Example 6.<span class="autoEx"/>: Access Evaluator (logback-examples/src/main/java/chapters/filters/accessEventEvaluator.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="STDOUT"
@@ -917,7 +917,7 @@ configuration (logback-examples/src/main/java/chapter6/duplicateMessage.xml)</em
CSS resources. Here is what such a configuration would look like:
</p>
- <em>Example 6.10: Access Evaluator (logback-examples/src/main/java/chapter6/accessEventEvaluator2.xml)</em>
+ <em>Example 6.10: Access Evaluator (logback-examples/src/main/java/chapters/filters/accessEventEvaluator2.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="STDOUT"
diff --git a/logback-site/src/site/pages/manual/jmxConfig.html b/logback-site/src/site/pages/manual/jmxConfig.html
index e7eb933..96eeb39 100644
--- a/logback-site/src/site/pages/manual/jmxConfig.html
+++ b/logback-site/src/site/pages/manual/jmxConfig.html
@@ -70,7 +70,7 @@
<p><a name="jmxConfigurator" href="#jmxConfigurator">Screen-shot
of <code>JMXConfigurator</code> viewed in
<code>jconsole</code></a></p>
- <img src="images/chapter9/jmxConfigurator.gif" alt="jmxConfigurator"/>
+ <img src="images/chapters/jmxConfigurator/jmxConfigurator.gif" alt="jmxConfigurator"/>
<p>Thus, you can</p>
@@ -95,7 +95,7 @@
<p>The status list can help you diagnose logbacks internal
state.</p>
- <img src="images/chapter9/statusList.gif" alt="statusList.gif"/>
+ <img src="images/chapters/jmxConfigurator/statusList.gif" alt="statusList.gif"/>
<h3><a name="leak" href="#leak">Avoiding memory leaks</a></h3>
@@ -176,7 +176,7 @@ public class MyContextListener implements ServletContextListener {
<p>In jconsole's MBeans panel, you would two distinct
<code>JMXConfigurator</code> instances:</p>
- <img src="images/chapter9/multiple.gif" alt="multiple.gif"/>
+ <img src="images/chapters/jmxConfigurator/multiple.gif" alt="multiple.gif"/>
<p>You may fully control the name under which JMXConfigurator is
registered with MBeans server with the help of the "objectName"
@@ -251,7 +251,7 @@ mvn jetty:run</p>
logback's <code>JMXConfigurator</code> via
<code>jconsole</code>.</p>
- <img src="images/chapter9/jconsole15_jetty.gif" alt="jconsole15_jetty.gif"/>
+ <img src="images/chapters/jmxConfigurator/jconsole15_jetty.gif" alt="jconsole15_jetty.gif"/>
<p>After you are connected, you should be able to access
<code>JMXXConfigurator</code> as shown in the <a
@@ -315,7 +315,7 @@ mvn jetty:run</p>
<p>Below is a screen shot view of the MX4J interface.</p>
- <img src="images/chapter9/mx4j_jetty.gif" alt="mx4j_jetty.gif"/>
+ <img src="images/chapters/jmxConfigurator/mx4j_jetty.gif" alt="mx4j_jetty.gif"/>
<!-- ================ Tomcat ================== -->
@@ -338,7 +338,7 @@ mvn jetty:run</p>
<p class="source">jconsole</p>
- <img src="images/chapter9/jconsole15_tomcat.gif" alt="jconsole15_tomcat.gif"/>
+ <img src="images/chapters/jmxConfigurator/jconsole15_tomcat.gif" alt="jconsole15_tomcat.gif"/>
<p>After you are connected, you should be able to access
<code>JMXXConfigurator</code> as shown in the <a
@@ -386,7 +386,7 @@ CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/mx4j-tools.jar</p>
<p>Below is a screen shot view of the MX4J interface.</p>
- <img src="images/chapter9/mx4j_tomcat.gif" alt="mx4j_tomcat.gif"/>
+ <img src="images/chapters/jmxConfigurator/mx4j_tomcat.gif" alt="mx4j_tomcat.gif"/>
diff --git a/logback-site/src/site/pages/manual/layouts.html b/logback-site/src/site/pages/manual/layouts.html
index adacb6b..35e165a 100644
--- a/logback-site/src/site/pages/manual/layouts.html
+++ b/logback-site/src/site/pages/manual/layouts.html
@@ -86,10 +86,10 @@
<p>Here is a possible implementation, authored by the Texan developer:</p>
<em>Example 5.0: Sample implementation of a Layout
- <a href="../xref/chapter5/MySampleLayout.html">
- (logback-examples/src/main/java/chapter5/MySampleLayout.java)</a></em>
+ <a href="../xref/chapters/layouts/MySampleLayout.html">
+ (logback-examples/src/main/java/chapters/layouts/MySampleLayout.java)</a></em>
- <pre class="prettyprint source">package chapter5;
+ <pre class="prettyprint source">package chapters.layouts;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.LayoutBase;
@@ -150,12 +150,12 @@ public class MySampleLayout extends LayoutBase<ILoggingEvent> {
example:</p>
<em>Example 5.0: Configuration of MySampleLayout
- (logback-examples/src/main/java/chapter5/sampleLayoutConfig.xml)</em>
+ (logback-examples/src/main/java/chapters/layouts/sampleLayoutConfig.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
- <b><layout class="chapter5.MySampleLayout" /></b>
+ <b><layout class="chapters.layouts.MySampleLayout" /></b>
</appender>
<root level="debug">
@@ -164,8 +164,8 @@ public class MySampleLayout extends LayoutBase<ILoggingEvent> {
</configuration></pre>
<p>The sample application <a
- href="../xref/chapter5/SampleLogging.html">
- <code>chapter5.SampleLogging</code></a> configures logback with
+ href="../xref/chapters/layouts/SampleLogging.html">
+ <code>chapters.layouts.SampleLogging</code></a> configures logback with
the configuration script supplied as a parameter and then logs a
debug message, followed by an error message. </p>
@@ -174,12 +174,12 @@ public class MySampleLayout extends LayoutBase<ILoggingEvent> {
<em>logback-examples</em> directory.
</p>
- <p class="command">java chapter5.SampleLogging src/main/java/chapter5/sampleLayoutConfig.xml</p>
+ <p class="command">java chapters.layouts.SampleLogging src/main/java/chapters/layouts/sampleLayoutConfig.xml</p>
<p> This will produce:</p>
-<div class="source"><pre>0 DEBUG [main] chapter5.SampleLogging - Everything's going well
-0 ERROR [main] chapter5.SampleLogging - maybe not quite...</pre></div>
+<div class="source"><pre>0 DEBUG [main] chapters.layouts.SampleLogging - Everything's going well
+0 ERROR [main] chapters.layouts.SampleLogging - maybe not quite...</pre></div>
<p>That was simple enough. The skeptic Pyrrho of Elea, who
insists that nothing is certain except perhaps uncertainty itself,
@@ -192,7 +192,7 @@ public class MySampleLayout extends LayoutBase<ILoggingEvent> {
<p>
The
- <a href="../xref/chapter5/MySampleLayout2.html"><code>MySampleLayout2</code>
+ <a href="../xref/chapters/layouts/MySampleLayout2.html"><code>MySampleLayout2</code>
</a>
class contains two attributes. The first one is a prefix that
can be added to the output. The second attribute is used to
@@ -201,7 +201,7 @@ public class MySampleLayout extends LayoutBase<ILoggingEvent> {
</p>
<p>Here is the implementation of this class:</p>
- <pre class="prettyprint source">package chapter5;
+ <pre class="prettyprint source">package chapters.layouts;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.LayoutBase;
@@ -257,7 +257,7 @@ public class MySampleLayout2 extends LayoutBase<ILoggingEvent> {
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
- <layout class="chapter5.MySampleLayout2">
+ <layout class="chapters.layouts.MySampleLayout2">
<b><prefix>MyPrefix</prefix></b>
<b><printThreadName>false</printThreadName></b>
</layout>
@@ -299,10 +299,10 @@ public class MySampleLayout2 extends LayoutBase<ILoggingEvent> {
</p>
<em>
Example 5.1: Sample usage of a PatternLayout
- <a href="../xref/chapter5/PatternSample.html">
- (logback-examples/src/main/java/chapter5/PatternSample.java)</a>
+ <a href="../xref/chapters/layouts/PatternSample.html">
+ (logback-examples/src/main/java/chapters/layouts/PatternSample.java)</a>
</em>
- <pre class="prettyprint source">package chapter5;
+ <pre class="prettyprint source">package chapters.layouts;
import org.slf4j.LoggerFactory;
@@ -1196,11 +1196,11 @@ Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>
<em>
Example 5.2: Sample usage of EventEvaluators
- (logback-examples/src/main/java/chapter5/callerEvaluatorConfig.xml)
+ (logback-examples/src/main/java/chapters/layouts/callerEvaluatorConfig.xml)
</em>
<pre class="prettyprint source"><configuration>
<b><evaluator name="DISP_CALLER_EVAL">
- <Expression>logger.getName().contains("chapter5") &amp;&amp; \
+ <Expression>logger.getName().contains("chapters.layouts") &amp;&amp; \
message.contains("who calls thee")</Expression>
</evaluator></b>
@@ -1224,11 +1224,11 @@ Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>
<p><em>
Example 5.2: Sample usage of EventEvaluators
- <a href="../xref/chapter5/CallerEvaluatorExample.html">
- (logback-examples/src/main/java/chapter5/CallerEvaluatorExample.java)</a>
+ <a href="../xref/chapters/layouts/CallerEvaluatorExample.html">
+ (logback-examples/src/main/java/chapters/layouts/CallerEvaluatorExample.java)</a>
</em>
</p>
- <pre class="prettyprint source">package chapter5;
+ <pre class="prettyprint source">package chapters.layouts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1283,7 +1283,7 @@ public class CallerEvaluatorExample {
0 [main] DEBUG - I know me 1
0 [main] DEBUG - I know me 2
0 [main] DEBUG - who calls thee?
-Caller+0 at chapter5.CallerEvaluatorExample.main(CallerEvaluatorExample.java:28)
+Caller+0 at chapters.layouts.CallerEvaluatorExample.main(CallerEvaluatorExample.java:28)
0 [main] DEBUG - I know me 4</pre></div>
<p>One can change the expression to correspond a real world
@@ -1310,11 +1310,11 @@ Caller+0 at chapter5.CallerEvaluatorExample.main(CallerEvaluatorExample.java:2
<p><em>
Example 5.2: Sample usage of EventEvaluators
- <a href="../xref/chapter5/ExceptionEvaluatorExample.html">
- (logback-examples/src/main/java/chapter5/ExceptionEvaluatorExample.java)</a>
+ <a href="../xref/chapters/layouts/ExceptionEvaluatorExample.html">
+ (logback-examples/src/main/java/chapters/layouts/ExceptionEvaluatorExample.java)</a>
</em>
</p>
-<pre class="prettyprint source">package chapter5;
+<pre class="prettyprint source">package chapters.layouts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1352,13 +1352,13 @@ public class ExceptionEvaluatorExample {
third logging request.</p>
<em>
Example 5.3: Sample usage of EventEvaluators
- (logback-examples/src/main/java/chapter5/exceptionEvaluatorConfig.xml)
+ (logback-examples/src/main/java/chapters/layouts/exceptionEvaluatorConfig.xml)
</em>
<pre class="prettyprint source"><configuration>
<b><evaluator name="DISPLAY_EX_EVAL">
<Expression>throwable != null &amp;&amp; throwable instanceof \
- chapter5.TestException</Expression>
+ chapters.layouts.TestException</Expression>
</evaluator></b>
<appender name="STDOUT"
@@ -1375,7 +1375,7 @@ public class ExceptionEvaluatorExample {
</configuration></pre>
<p>With this configuration, each time an instance of the
- <em>chapter5.TestException</em> is included within a logging
+ <em>chapters.layouts.TestException</em> is included within a logging
request, the stack trace will be suppressed.
</p>
@@ -1412,9 +1412,9 @@ public class ExceptionEvaluatorExample {
conventions. Here is a possible implementation:</p>
<em> Example 5.4: Sample Converter Example
-<a href="../xref/chapter5/MySampleConverter.html">
-(src/main/java/chapter5/MySampleConverter.java)</a></em>
-<pre class="prettyprint source">package chapter5;
+<a href="../xref/chapters/layouts/MySampleConverter.html">
+(src/main/java/chapters/layouts/MySampleConverter.java)</a></em>
+<pre class="prettyprint source">package chapters.layouts;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.pattern.ClassicConverter;
@@ -1464,10 +1464,10 @@ public class MySampleConverter extends ClassicConverter {
<code>Converter</code>. For this purpose, we need to declare the
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>
+<em> Example 5.4: Sample Converter Example (src/main/java/chapters/layouts/mySampleConverterConfig.xml)</em>
<pre class="prettyprint source"><configuration>
- <b><conversionRule conversionWord="sample" converterClass="chapter5.MySampleConverter" /></b>
+ <b><conversionRule conversionWord="sample" converterClass="chapters.layouts.MySampleConverter" /></b>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
@@ -1490,7 +1490,7 @@ public class MySampleConverter extends ClassicConverter {
view the results on non-Windows platforms such as Linux or
Mac. The following command:</p>
- <div class="source">java chapter5.SampleLogging src/main/java/chapter5/mySampleConverterConfig.xml </div>
+ <div class="source">java chapters.layouts.SampleLogging src/main/java/chapters/layouts/mySampleConverterConfig.xml </div>
<p>should yield:</p>
diff --git a/logback-site/src/site/pages/manual/mdc.html b/logback-site/src/site/pages/manual/mdc.html
index a31ebfd..6529648 100644
--- a/logback-site/src/site/pages/manual/mdc.html
+++ b/logback-site/src/site/pages/manual/mdc.html
@@ -96,12 +96,12 @@ public class MDC {
<p>
The next application named
- <code><a href="../xref/chapter7/SimpleMDC.html">SimpleMDC</a></code>
+ <code><a href="../xref/chapters/mdc/SimpleMDC.html">SimpleMDC</a></code>
demonstrates this basic principle.
</p>
-<em>Example 7.1: Basic MDC usage (<a href="../xref/chapter7/SimpleMDC.html">
-logback-examples/src/main/java/chapter7/SimpleMDC.java)</a></em>
-<pre class="prettyprint source">package chapter7;
+<em>Example 7.1: Basic MDC usage (<a href="../xref/chapters/mdc/SimpleMDC.html">
+logback-examples/src/main/java/chapters/mdc/SimpleMDC.java)</a></em>
+<pre class="prettyprint source">package chapters.mdc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -213,9 +213,9 @@ Richard Nixon - Attributed to the former US president. 17 Nov 1973.</pre></div>
retrieve the distinct factors of an integer.
</p>
-<em>Example 7.2: The service interface (<a href="../xref/chapter7/NumberCruncher.html">
-logback-examples/src/main/java/chapter7/NumberCruncher.java)</a></em>
-<pre class="prettyprint source">package chapter7;
+<em>Example 7.2: The service interface (<a href="../xref/chapters/mdc/NumberCruncher.html">
+logback-examples/src/main/java/chapters/mdc/NumberCruncher.java)</a></em>
+<pre class="prettyprint source">package chapters.mdc;
import java.rmi.Remote;
import java.rmi.RemoteException;
@@ -237,9 +237,9 @@ public interface NumberCruncher extends Remote {
an RMI Registry on the local host that accepts requests on a well-known port.
</p>
-<em>Example 7.3: The server side (<a href="../xref/chapter7/NumberCruncherServer.html">
-logback-examples/src/main/java/chapter7/NumberCruncherServer.java)</a></em>
-<pre class="prettyprint source">package chapter7;
+<em>Example 7.3: The server side (<a href="../xref/chapters/mdc/NumberCruncherServer.html">
+logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java)</a></em>
+<pre class="prettyprint source">package chapters.mdc;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
@@ -341,7 +341,7 @@ public class NumberCruncherServer extends UnicastRemoteObject
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java chapter7.NumberCruncherServer configFile\n" +
+ System.err.println("Usage: java chapters.mdc.NumberCruncherServer configFile\n" +
" where configFile is a logback configuration file.");
System.exit(1);
}
@@ -412,12 +412,12 @@ public class NumberCruncherServer extends UnicastRemoteObject
cruncher example. Start the server with the following command:
</p>
-<div class="source"><pre>java chapter7.NumberCruncherServer src/main/java/chapter7/mdc1.xml</pre></div>
+<div class="source"><pre>java chapters.mdc.NumberCruncherServer src/main/java/chapters/mdc/mdc1.xml</pre></div>
<p>
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>
+<em>Example 7.4: Configuration file (logback-examples/src/main/java/chapters/mdc/mdc1.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout>
@@ -440,7 +440,7 @@ public class NumberCruncherServer extends UnicastRemoteObject
application:
</p>
-<div class="source"><pre>java chapter7.NumberCruncherClient <em>hostname</em></pre></div>
+<div class="source"><pre>java chapters.mdc.NumberCruncherClient <em>hostname</em></pre></div>
<p>
where <em>hostname</em> is the host where the
@@ -530,9 +530,9 @@ public class NumberCruncherServer extends UnicastRemoteObject
<p>Here is an implementation of such a filter:</p>
-<em>Example 7.5: User servlet filter (<a href="../xref/chapter7/UserServletFilter.html">
-logback-examples/src/main/java/chapter7/UserServletFilter.java)</a></em>
-<pre class="prettyprint source">package chapter7;
+<em>Example 7.5: User servlet filter (<a href="../xref/chapters/mdc/UserServletFilter.html">
+logback-examples/src/main/java/chapters/mdc/UserServletFilter.java)</a></em>
+<pre class="prettyprint source">package chapters.mdc;
import java.io.IOException;
import java.security.Principal;
diff --git a/logback-site/src/site/pages/manual/migrationFromLog4j.html b/logback-site/src/site/pages/manual/migrationFromLog4j.html
index ed7cd04..386dbb4 100644
--- a/logback-site/src/site/pages/manual/migrationFromLog4j.html
+++ b/logback-site/src/site/pages/manual/migrationFromLog4j.html
@@ -69,13 +69,13 @@
<p>Let us begin by migrating a hypothetcical and trivially simple
log4j layout named <a
- href="../xref/chapter11/TrivialLog4jLayout.html">TrivialLog4jLayout</a>
+ href="../xref/chapters/migrationFromLog4j/TrivialLog4jLayout.html">TrivialLog4jLayout</a>
which returns the message contained in a logging events as the
formatted message. Here is the code.
</p>
- <pre class="prettyprint source">package chapter11;
+ <pre class="prettyprint source">package chapters.migrationFromLog4j;
import org.apache.log4j.Layout;
import org.apache.log4j.spi.LoggingEvent;
@@ -96,10 +96,10 @@ public class TrivialLog4jLayout extends Layout {
}</pre>
<p>The logback-classic equivalent named <a
- href="../xref/chapter11/TrivialLogbackLayout.html">TrivialLogbackLayout</a>
+ href="../xref/chapters/migrationFromLog4j/TrivialLogbackLayout.html">TrivialLogbackLayout</a>
would be </p>
- <pre class="prettyprint source">package chapter11;
+ <pre class="prettyprint source">package chapters.migrationFromLog4j;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.LayoutBase;
@@ -140,10 +140,10 @@ public class TrivialLogbackLayout extends <b>LayoutBase<ILoggingEvent></b> {
<p>Migrating an appender is quite similar to migrating layout. Here
is a trivially simple appender called <a
- href="../xref/chapter11/TrivialLog4jLayout.html">TrivialLog4jLayout</a>
+ href="../xref/chapters/migrationFromLog4j/TrivialLog4jLayout.html">TrivialLog4jLayout</a>
which writes on the console the string returned by its layout.</p>
- <pre class="prettyprint source">package chapter11;
+ <pre class="prettyprint source">package chapters.migrationFromLog4j;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
@@ -166,11 +166,11 @@ public class TrivialLog4jAppender extends AppenderSkeleton {
}</pre>
<p>The logback-classic equivalent named <a
- href="../xref/chapter11/TrivialLogbackAppender.html">TrivialLogbackAppender</a>
+ href="../xref/chapters/migrationFromLog4j/TrivialLogbackAppender.html">TrivialLogbackAppender</a>
would be written as</p>
- <pre class="prettyprint source">package chapter11;
+ <pre class="prettyprint source">package chapters.migrationFromLog4j;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
diff --git a/logback-site/src/site/pages/manual/onJoran.html b/logback-site/src/site/pages/manual/onJoran.html
index eab4c87..b44a270 100644
--- a/logback-site/src/site/pages/manual/onJoran.html
+++ b/logback-site/src/site/pages/manual/onJoran.html
@@ -47,7 +47,7 @@
</p>
<p>The examples presented in this chapter can be found under
- <em>LOGBACK_HOME/logback-examples/src/main/java/chapter10</em>
+ <em>LOGBACK_HOME/logback-examples/src/main/java/chapters/onJoran/</em>
folder.
</p>
@@ -248,15 +248,15 @@ public abstract class Action {
<p>The first example in this chapter illustrates the minimal
plumbing required for using Joran. The example consists of a
trivial action called <a
- href="../xref/chapter10/helloWorld/HelloWorldAction.html">
+ href="../xref/chapters/onJoran/helloWorld/HelloWorldAction.html">
<code>HelloWorldAction</code></a> which prints "Hello World" on the
console when it's <code>begin()</code> method is invoked. The
parsing of XML files is done by a configurator. For the purposes of
this chapter, we have developped a very simple configurator called
<a
- href="../xref/chapter10/SimpleConfigurator.html"><code>SimpleConfigurator</code></a>.
+ href="../xref/chapters/onJoran/SimpleConfigurator.html"><code>SimpleConfigurator</code></a>.
The <a
- href="../xref/chapter10/helloWorld/HelloWorld.html"><code>HelloWorld</code></a>
+ href="../xref/chapters/onJoran/helloWorld/HelloWorld.html"><code>HelloWorld</code></a>
application brings all pieces together.
</p>
@@ -276,14 +276,14 @@ public abstract class Action {
<p>The <em>hello.xml</em> file contains one <hello-world>
element, without any other nested elements. See the
- <em>logback-examples/src/main/java/chapter10/helloWorld/</em>
+ <em>logback-examples/src/main/java/chapters/onJoran/helloWorld/</em>
folder for exact contents.
</p>
<p>Running the HelloWorld application with <em>hello.xml</em> file
will print "Hello World" on the console.</p>
- <p class="command">java chapter10.helloWorld.HelloWorld src/main/java/chapter10/helloWorld/hello.xml</p>
+ <p class="command">java chapters.onJoran.helloWorld.HelloWorld src/main/java/chapters/onJoran/helloWorld/hello.xml</p>
<p>You are highly encourared to poke about this example, by adding
new rules on the rule store, modifying the XML document
@@ -307,14 +307,14 @@ public abstract class Action {
</p>
<em>Example 10.<span class="autoEx"/>: First calculator example
- (logback-examples/src/main/java/chapter10/calculator/calculator1.xml)</em>
+ (logback-examples/src/main/java/chapters/onJoran/calculator/calculator1.xml)</em>
<em> </em>
<pre class="prettyprint source"><computation name="total">
<literal value="3"/>
</computation></pre>
- <p>In the <a href="../xref/chapter10/calculator/Calculator1.html">
+ <p>In the <a href="../xref/chapters/onJoran/calculator/Calculator1.html">
<code>Calculator1</code></a> application, we declare various
parsing rules (patterns and actions) collaborating together to
compute a result based on the contents of an XML document.
@@ -323,7 +323,7 @@ public abstract class Action {
<p> Running <code>Calculator1</code> application with
<em>calculator1.xml</em></p>
- <p class="command">java chapter10.calculator.Calculator1 src/main/java/chapter10/calculator/calculator1.xml</p>
+ <p class="command">java chapters.onJoran.calculator.Calculator1 src/main/java/chapters/onJoran/calculator/calculator1.xml</p>
<p>will print:</p>
@@ -338,11 +338,11 @@ public abstract class Action {
<li>The start event corresponding to the <computation>
element translates into the current pattern
"/computation". Since in the <a
- href="../xref/chapter10/calculator/Calculator1.html">
+ href="../xref/chapters/onJoran/calculator/Calculator1.html">
<code>Calculator1</code></a> application we associated the
pattern "/computation" with a
<a
- href="../xref/chapter10/calculator/ComputationAction1.html">
+ href="../xref/chapters/onJoran/calculator/ComputationAction1.html">
<code>ComputationAction1</code></a> instance, the
<code>begin()</code> method of that
<code>ComputationAction1</code> instance is invoked.
@@ -353,7 +353,7 @@ public abstract class Action {
"/computation/literal". Given the association of the
"/computation/literal" pattern with a
<a
- href="../xref/chapter10/calculator/LiteralAction.html">
+ href="../xref/chapters/onJoran/calculator/LiteralAction.html">
<code>LiteralAction</code></a> instance, the
<code>begin()</code> method of that <code>LiteralAction</code>
instance is called.</p>
@@ -390,7 +390,7 @@ public abstract class Action {
<em>Example 10.<span class="autoEx"/>: Calculator configuration
file
- (logback-examples/src/main/java/chapter10/calculator/calculator2.xml)</em>
+ (logback-examples/src/main/java/chapters/onJoran/calculator/calculator2.xml)</em>
<pre class="prettyprint source"><computation name="toto">
<literal value="7"/>
<literal value="3"/>
@@ -402,19 +402,19 @@ public abstract class Action {
<p>As in the previous example, in response to the <literal>
element,the appropriate <a
- href="../xref/chapter10/calculator/LiteralAction.html">
+ href="../xref/chapters/onJoran/calculator/LiteralAction.html">
<code>LiteralAction</code></a> instance will push an integer,
corresponding to the value attribute, at the top of the
interpretation context's object stack. In this example, that is
<em>calculator2.xml</em>, the values are 7 and 3. In response to the
<add> element, the appropriate <a
- href="../xref/chapter10/calculator/AddAction.html"><code>AddAction</code></a>
+ href="../xref/chapters/onJoran/calculator/AddAction.html"><code>AddAction</code></a>
will pop two previously pushed integers, compute their sum and push
the result, i.e. 10 (=7+3), at the top of the interpretation
context's stack. The next literal element will cause LiteralAction
to push an integer with value 3 at the top of the stack. In response
to the <multiply> element, the appropriate <a
- href="../xref/chapter10/calculator/MultiplyAction.html"><code>MultiplyAction</code></a>
+ href="../xref/chapters/onJoran/calculator/MultiplyAction.html"><code>MultiplyAction</code></a>
will pop two previously pushed integers, i.e. 10 and 3, and compute
their product. It will push the result, i.e. 30, at the top of the
stack. At the very end, in reponse to the end event corresponding to
@@ -422,7 +422,7 @@ public abstract class Action {
object at the top of the stack. Thus, running:
</p>
- <p class="command">java chapter10.calculator.Calculator1 src/main/java/chapter10/calculator/calculator2.xml </p>
+ <p class="command">java chapters.onJoran.calculator.Calculator1 src/main/java/chapters/onJoran/calculator/calculator2.xml </p>
<p>will yield</p>
@@ -437,7 +437,7 @@ public abstract class Action {
same element. Here's the content of <em>calculator3.xml</em>:</p>
<em>Example 10.<span class="autoEx"/>: Calculator configuration file
- (logback-examples/src/main/java/chapter10/calculator/calculator3.xml)</em>
+ (logback-examples/src/main/java/chapters/onJoran/calculator/calculator3.xml)</em>
<pre class="prettyprint source"><computation name="toto">
<computation>
@@ -453,7 +453,7 @@ public abstract class Action {
<p>Much like the use of parentheses in an algebrical equation, the
presence of a <code>computation</code> element nested in another is
managed by the <a
- href="../xref/chapter10/calculator/ComputationAction2.html">
+ href="../xref/chapters/onJoran/calculator/ComputationAction2.html">
<code>ComputationAction2</code></a> class using an internal
stack. The well-formedness of XML will guarantee that a value saved
by one <code>begin()</code> will be consumed only by the matching
@@ -496,19 +496,19 @@ public abstract class Action {
<p>You can create and register a custom implicit action as
illustrated in the next example contained within the
- <em>logback-examples/src/main/java/chapter10/implicit</em> folder.
+ <em>logback-examples/src/main/java/chapters/onJoran/implicit</em> folder.
</p>
<p>The <a
- href="../xref/chapter10/implicit/PrintMe.html"><code>PrintMe</code></a>
+ href="../xref/chapters/onJoran/implicit/PrintMe.html"><code>PrintMe</code></a>
application associates an <a
- href="../xref/chapter10/implicit/NOPAction.html">
+ href="../xref/chapters/onJoran/implicit/NOPAction.html">
<code>NOPAction</code></a> instance with the pattern "*/foo", that
is any element named as "foo". As its name indicates, the
<code>begin</code>() and <code>end</code>() methods of
<code>NOPAction</code> are empty. The <code>PrintMe</code>
application also registers an instance of <a
- href="../xref/chapter10/implicit/PrintMeImplicitAction.html">PrintMeImplicitAction</a>
+ href="../xref/chapters/onJoran/implicit/PrintMeImplicitAction.html">PrintMeImplicitAction</a>
in its list of implicit actions. The
<code>PrintMeImplicitAction</code> is applicable for any element
which has a <span class="attr">printme</span> attribute set to
@@ -522,7 +522,7 @@ public abstract class Action {
how implicit actions come into play.</p>
<em>Example 10.<span class="autoEx"/>: Usage of implicit rules
- (logback-examples/src/main/java/chapter10/implicit/implicit1.xml)</em>
+ (logback-examples/src/main/java/chapters/onJoran/implicit/implicit1.xml)</em>
<pre class="prettyprint source"><foo>
<xyz printme="true">
<abc printme="true"/>
@@ -536,7 +536,7 @@ public abstract class Action {
<p>Running</p>
- <p class="command">java chapter10.implicit.PrintMe src/main/java/chapter10/implicit/implicit1.xml</p>
+ <p class="command">java chapters.onJoran.implicit.PrintMe src/main/java/chapters/onJoran/implicit/implicit1.xml</p>
<p>yields:</p>
<p class="console">Element [xyz] asked to be printed.
@@ -693,9 +693,9 @@ Element [abc] asked to be printed.
<p>Joran includes an action which allows the Joran interpreter to
learn new rules on the fly, that is while interpreting an XML
document. See the
- <em>logback-examples/src/main/java/chapter10/newRule/</em> directory
+ <em>logback-examples/src/main/java/chapters/onJoran/newRule/</em> directory
for sample code. In this package, the <a
- href="../xref/chapter10/newRule/NewRuleCalculator.html">
+ href="../xref/chapters/onJoran/newRule/NewRuleCalculator.html">
<code>NewRuleCalculator</code></a> application sets up just two
rules, one rule to process the top-most element, and a second rule
to learn new rules. Here is the relevant code from
@@ -719,7 +719,7 @@ Element [abc] asked to be printed.
<p>Here is how new rules can be declared in an xml file:</p>
<pre class="prettyprint source"><new-rule pattern="*/computation/literal"
- actionClass="chapter10.calculator.LiteralAction"/></pre>
+ actionClass="chapters.onJoran.calculator.LiteralAction"/></pre>
<p>Using such new-rule declarations, we can transform
<code>NewRuleCalculator</code> to behave like the
@@ -728,15 +728,15 @@ Element [abc] asked to be printed.
<em>Example 10..<span class="autoEx"/>: Configuration file using new
rules on the fly
- (logback-examples/src/main/java/chapter10/newrule/new-rule.xml)</em>
+ (logback-examples/src/main/java/chapters/onJoran/newrule/new-rule.xml)</em>
<pre class="prettyprint source"><computation name="toto">
<new-rule pattern="*/computation/literal"
- actionClass="chapter10.calculator.LiteralAction"/>
+ actionClass="chapters.onJoran.calculator.LiteralAction"/>
<new-rule pattern="*/computation/add"
- actionClass="chapter10.calculator.AddAction"/>
+ actionClass="chapters.onJoran.calculator.AddAction"/>
<new-rule pattern="*/computation/multiply"
- actionClass="chapter10.calculator.MultiplyAction"/>
+ actionClass="chapters.onJoran.calculator.MultiplyAction"/>
<computation>
<literal value="7"/>
@@ -749,7 +749,7 @@ Element [abc] asked to be printed.
</computation></pre>
- <p class="command">java java chapter10.newRule.NewRuleCalculator src/main/java/chapter10/newRule/new-rule.xml</p>
+ <p class="command">java java chapters.onJoran.newRule.NewRuleCalculator src/main/java/chapters/onJoran/newRule/new-rule.xml</p>
<p>yields</p>
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 2b2c803..fa1ef89 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -59,13 +59,13 @@
</div>
<p><code>FileAppender</code> and derived classes can now
- gracefully deal with IO failreus and recover quickly after the
+ gracefully deal with IO failures and recover quickly after the
original cause of the IO failure is corrected. For example, if the
log file is located on a <a
href="http://en.wikipedia.org/wiki/Network-attached_storage">network-attached
storage (NAS)</a>, and the connection to the NAS server is lost,
<code>FileAppender</code> and derived classes will recover quickly
- after the connection to the server is re-established.
+ after the connection to the server is re-established.
</p>
<p>Added <a
diff --git a/logback-site/src/site/pages/setup.html b/logback-site/src/site/pages/setup.html
index 4f5d924..71093ef 100644
--- a/logback-site/src/site/pages/setup.html
+++ b/logback-site/src/site/pages/setup.html
@@ -44,12 +44,12 @@
<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>chapter1.HelloWord1</em> with the following command:
+ <em>chapters.introduction.HelloWord1</em> with the following command:
</p>
<p class="source">java -cp lib/slf4j-api-${slf4j.version}.jar;../logback-core-${version}.jar;\
../logback-classic-${version}.jar;logback-examples-${version}.jar\
- chapter1.HelloWorld1</p>
+ chapters.introduction.HelloWorld1</p>
<p>It is more convenient to set the CLASSPATH environment variable
once and for all before running the examples.
diff --git a/logback-site/src/site/resources/manual/images/chapters/configuration/sample.xml b/logback-site/src/site/resources/manual/images/chapters/configuration/sample.xml
deleted file mode 100644
index aa8e4b8..0000000
--- a/logback-site/src/site/resources/manual/images/chapters/configuration/sample.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>myApp.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <FileNamePattern> myApp-%d{yyyy-MM-dd-HH-mm-ss}.log</FileNamePattern>
- </rollingPolicy>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</Pattern>
- </layout>
- </appender>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%msg%n</Pattern>
- </layout>
- </appender>
- <logger name="chapter3">
- <appender-ref ref="FILE"/>
- </logger>
- <logger name="chapter4">
- <appender-ref ref="FILE"/>
- </logger>
- <root>
- <level value="debug"/>
- <appender-ref ref="STDOUT"/>
- </root>
-</configuration>
-----------------------------------------------------------------------
Summary of changes:
.../core/recovery/ResilientFileOutputStream.java | 4 +-
.../main/java/chapters/appenders/mail/mail3.xml | 2 +-
.../java/chapters/architecture/sample-config-3.xml | 2 +-
.../chapters/configuration/containingConfig.xml | 2 +-
.../configuration/variableSubstitution3.xml | 2 +-
.../configuration/variableSubstitution4.xml | 2 +-
.../java/chapters/filters/sampleFilterConfig.xml | 2 +-
.../chapters/filters/sampleTurboFilterConfig.xml | 2 +-
.../chapters/layouts/callerEvaluatorConfig.xml | 2 +-
.../chapters/layouts/exceptionEvaluatorConfig.xml | 2 +-
.../chapters/layouts/mySampleConverterConfig.xml | 2 +-
.../java/chapters/layouts/sampleLayoutConfig.xml | 2 +-
.../java/chapters/layouts/sampleLayoutConfig2.xml | 2 +-
.../java/chapters/mdc/NumberCruncherClient.java | 2 +-
.../java/chapters/mdc/NumberCruncherServer.java | 2 +-
.../src/main/java/chapters/mdc/SimpleMDC.java | 4 +-
.../main/java/chapters/mdc/UserServletFilter.java | 2 +-
.../chapters/migrationFromLog4j/Log4jMain.java | 2 +-
.../chapters/migrationFromLog4j/LogbackMain.java | 2 +-
.../migrationFromLog4j/log4jTrivial.properties | 4 +-
.../migrationFromLog4j/logback-trivial.xml | 4 +-
.../onJoran/SimpleConfigurator.java | 2 +-
.../onJoran/calculator/AddAction.java | 2 +-
.../onJoran/calculator/Calculator1.java | 4 +-
.../onJoran/calculator/Calculator2.java | 4 +-
.../onJoran/calculator/ComputationAction1.java | 2 +-
.../onJoran/calculator/ComputationAction2.java | 2 +-
.../onJoran/calculator/LiteralAction.java | 2 +-
.../onJoran/calculator/MultiplyAction.java | 2 +-
.../onJoran/calculator/calculator1.xml | 0
.../onJoran/calculator/calculator2.xml | 0
.../onJoran/calculator/calculator3.xml | 1 -
.../{appenders => }/onJoran/calculator/readme.txt | 0
.../onJoran/helloWorld/HelloWorld.java | 4 +-
.../onJoran/helloWorld/HelloWorldAction.java | 2 +-
.../{appenders => }/onJoran/helloWorld/hello.xml | 0
.../{appenders => }/onJoran/helloWorld/readme.txt | 0
.../onJoran/implicit/NOPAction.java | 2 +-
.../{appenders => }/onJoran/implicit/PrintMe.java | 4 +-
.../onJoran/implicit/PrintMeImplicitAction.java | 2 +-
.../{appenders => }/onJoran/implicit/implicit1.xml | 0
.../{appenders => }/onJoran/implicit/readme.txt | 0
.../onJoran/newRule/NewRuleCalculator.java | 6 +-
.../{appenders => }/onJoran/newRule/new-rule.xml | 6 +-
.../{appenders => }/onJoran/newRule/readme.txt | 0
logback-site/src/site/pages/faq.html | 2 +-
logback-site/src/site/pages/index.html | 4 +-
logback-site/src/site/pages/manual/appenders.html | 2 +-
logback-site/src/site/pages/manual/filters.html | 122 ++++++++++----------
logback-site/src/site/pages/manual/jmxConfig.html | 14 +-
logback-site/src/site/pages/manual/layouts.html | 68 ++++++------
logback-site/src/site/pages/manual/mdc.html | 34 +++---
.../src/site/pages/manual/migrationFromLog4j.html | 16 ++--
logback-site/src/site/pages/manual/onJoran.html | 66 ++++++------
logback-site/src/site/pages/news.html | 4 +-
logback-site/src/site/pages/setup.html | 4 +-
.../images/chapters/configuration/sample.xml | 32 -----
57 files changed, 217 insertions(+), 248 deletions(-)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/SimpleConfigurator.java (97%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/AddAction.java (97%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/Calculator1.java (94%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/Calculator2.java (95%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/ComputationAction1.java (97%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/ComputationAction2.java (98%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/LiteralAction.java (97%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/MultiplyAction.java (97%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/calculator1.xml (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/calculator2.xml (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/calculator3.xml (95%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/calculator/readme.txt (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/helloWorld/HelloWorld.java (93%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/helloWorld/HelloWorldAction.java (95%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/helloWorld/hello.xml (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/helloWorld/readme.txt (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/implicit/NOPAction.java (95%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/implicit/PrintMe.java (95%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/implicit/PrintMeImplicitAction.java (96%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/implicit/implicit1.xml (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/implicit/readme.txt (100%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/newRule/NewRuleCalculator.java (92%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/newRule/new-rule.xml (67%)
copy logback-examples/src/main/java/chapters/{appenders => }/onJoran/newRule/readme.txt (100%)
delete mode 100644 logback-site/src/site/resources/manual/images/chapters/configuration/sample.xml
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list