logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1410726 [2/3] - in /logging/log4j/log4j2/trunk/src/site: resources/css/ xdoc/ xdoc/manual/
Date Sat, 17 Nov 2012 13:11:47 GMT
Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/configuration.xml.vm
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/configuration.xml.vm?rev=1410726&r1=1410725&r2=1410726&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/configuration.xml.vm (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/configuration.xml.vm Sat Nov 17 13:11:44 2012
@@ -83,28 +83,29 @@
             this is done.
           </p>
           <p>
-<source> import com.foo.Bar;
+<pre class="prettyprint linenums">
+import com.foo.Bar;
 
- // Import log4j classes.
- import org.apache.logging.log4j.Logger;
+// Import log4j classes.
+import org.apache.logging.log4j.Logger;
 
- public class MyApp {
+public class MyApp {
 
-   // Define a static logger variable so that it references the
-   // Logger instance named "MyApp".
-   Logger logger = LogManager.getLogger(MyApp.class.getName());
+// Define a static logger variable so that it references the
+// Logger instance named "MyApp".
+Logger logger = LogManager.getLogger(MyApp.class.getName());
 
-   public static void main(String[] args) {
+public static void main(String[] args) {
 
-   // Set up a simple configuration that logs on the console.
+// Set up a simple configuration that logs on the console.
 
-   logger.trace("Entering application.");
-   Bar bar = new Bar();
-   if (!bar.doIt() {
-     logger.error("Didn't do it.");
-   }
-   logger.trace("Exiting application.");                 }
- }</source>
+logger.trace("Entering application.");
+Bar bar = new Bar();
+if (!bar.doIt() {
+  logger.error("Didn't do it.");
+}
+logger.trace("Exiting application.");                 }
+}</pre>
           </p>
           <p>
             <code>MyApp</code> begins by importing log4j related classes. It
@@ -115,18 +116,19 @@
             <code>MyApp</code> uses the <code>Bar</code> class defined in the package<code>com.foo</code>.
           </p>
           <p>
-<source>  package com.foo;
-  import org.apache.logging.log4j.Logger;
-
-  public class Bar {
-    static Logger logger = LogManager.getLogger(Bar.class.getName());
-
-    public boolean doIt() {
-      logger.entry();
-      logger.error("Did it again!");
-      return logger.exit(false);
-    }
-  }</source>
+<pre class="prettyprint linenums">
+package com.foo;
+import org.apache.logging.log4j.Logger;
+
+public class Bar {
+  static Logger logger = LogManager.getLogger(Bar.class.getName());
+
+  public boolean doIt() {
+    logger.entry();
+    logger.error("Did it again!");
+    return logger.exit(false);
+  }
+}</pre>
           </p>
           <p>
             If no configuration files are present logback will default to the DefaultConfiguration which
@@ -140,15 +142,15 @@
             Note that by default, the root logger is assigned to <code>Level.ERROR</code>.
           </p>
           <p>The output of MyApp would be similar to:
-            <pre>
-  17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
-  17:13:01.540 [main] ERROR MyApp - Didn't do it.
-            </pre>
+<pre class="prettyprint linenums">
+17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
+17:13:01.540 [main] ERROR MyApp - Didn't do it.</pre>
           </p>
           <p>
             As was described previously, Log4j will first attempt to configure itself from configuration files. A
             configuration equivalent to the default would look like:
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+          <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="OFF">
   <appenders>
     <Console name="Console" target="SYSTEM_OUT">
@@ -160,16 +162,16 @@
       <appender-ref ref="Console"/>
     </root>
   </loggers>
-</configuration>]]></source>
+</configuration>]]></pre>
             Once the file above is placed into the classpath as log4j2.xml you will get results identical to
             those listed above. Changing the root level to trace will result in results similar to:
-             <source>
-  17:13:01.540 [main] TRACE MyApp - Entering application.
-  17:13:01.540 [main] TRACE com.foo.Bar - entry
-  17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
-  17:13:01.540 [main] TRACE com.foo.Bar - exit with (false)
-  17:13:01.540 [main] ERROR MyApp - Didn't do it.
-  17:13:01.540 [main] TRACE MyApp - Exiting application.</source>
+             <pre>
+17:13:01.540 [main] TRACE MyApp - Entering application.
+17:13:01.540 [main] TRACE com.foo.Bar - entry
+17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
+17:13:01.540 [main] TRACE com.foo.Bar - exit with (false)
+17:13:01.540 [main] ERROR MyApp - Didn't do it.
+17:13:01.540 [main] TRACE MyApp - Exiting application.</pre>
           </p>
           <p>
             Note that status logging is disabled when the default configuration is used.
@@ -179,10 +181,11 @@
             changing the log level would not accomplish the task. Instead, the solution is to
             add a new logger definition to the configuration:
           </p>
-            <source><![CDATA[    <logger name="com.foo.Bar" level="TRACE"/>
-    <root level="ERROR">
-      <appender-ref ref="STDOUT">
-    </root>]]></source>
+            <pre class="prettyprint linenums"><![CDATA[
+<logger name="com.foo.Bar" level="TRACE"/>
+<root level="ERROR">
+  <appender-ref ref="STDOUT">
+</root>]]></pre>
           <p>
             With this configuration all log events from <code>com.foo.Bar</code> will be recorded while only error events will
             be recorded from all other components.
@@ -195,7 +198,8 @@
             because the logger for <code>com.foo.Bar</code> did not have any appenders configured while its parent did. In fact,
             the following configuration
           </p>
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+          <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="OFF">
   <appenders>
     <Console name="Console" target="SYSTEM_OUT">
@@ -210,15 +214,15 @@
       <appender-ref ref="Console"/>
     </root>
   </loggers>
-</configuration>]]></source>
+</configuration>]]></pre>
           <p>would result in</p>
-             <source>
-  17:13:01.540 [main] TRACE com.foo.Bar - entry
-  17:13:01.540 [main] TRACE com.foo.Bar - entry
-  17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
-  17:13:01.540 [main] TRACE com.foo.Bar - exit (false)
-  17:13:01.540 [main] TRACE com.foo.Bar - exit (false)
-  17:13:01.540 [main] ERROR MyApp - Didn't do it.</source>
+             <pre class="prettyprint linenums">
+17:13:01.540 [main] TRACE com.foo.Bar - entry
+17:13:01.540 [main] TRACE com.foo.Bar - entry
+17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
+17:13:01.540 [main] TRACE com.foo.Bar - exit (false)
+17:13:01.540 [main] TRACE com.foo.Bar - exit (false)
+17:13:01.540 [main] ERROR MyApp - Didn't do it.</pre>
           <p>Notice that the trace messages from <code>com.foo.Bar</code> appear twice. This is because the appender associated
             with logger <code>com.foo.Bar</code> is first used, which writes the first instance to the Console. Next, the parent
             of <code>com.foo.Bar</code>, which in this case is the root logger, is referenced. The event is then passed to its
@@ -227,7 +231,7 @@
             no appender reference needed to be configured), in many cases this behavior is considered undesirable
             and so it is possible to disable it by setting the additivity attribute on the logger to false:
           </p>
-           <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+           <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="OFF">
   <appenders>
     <Console name="Console" target="SYSTEM_OUT">
@@ -242,7 +246,7 @@
       <appender-ref ref="Console"/>
     </root>
   </loggers>
-</configuration>]]></source>
+</configuration>]]></pre>
           <p>
             Once an event reaches a logger with its additivity set to false the event will not be passed to
             any of its parent loggers, regardless of their additivity setting.
@@ -258,10 +262,11 @@
             to configure the attribute so that the configuration file will be checked for changes only after at
             least 30 seconds have elapsed.  The minimum interval is 5 seconds.
           </p>
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+          <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
 <configuration monitorInterval="30">
 ...
-</configuration>]]></source>
+</configuration>]]></pre>
         </subsection>
         <a name="ConfigurationSyntax"/>
         <subsection name="Configuration Syntax">
@@ -326,11 +331,12 @@
             and attribute names are are not case sensitive. In addition, attributes can either be specified
             as an XML attribute or as an XML element that has no attributes and has a text value. So
           </p>
-          <source><![CDATA[<patternLayout pattern="%m%n"/>]]></source>
+          <pre class="prettyprint"><![CDATA[<patternLayout pattern="%m%n"/>]]></pre>
           <p>and</p>
-          <source><![CDATA[<PatternLayout>
+          <pre class="prettyprint"><![CDATA[
+<PatternLayout>
   <pattern>%m%n</pattern>
-</PatternLayout>]]></source>
+</PatternLayout>]]></pre>
           <p>
             are equivalent.
           </p>
@@ -339,7 +345,8 @@
             that the elements in italics below represent the concise element names that would appear in their place.
           </p>
 
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
+          <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>;
 <configuration>
   <properties>
     <property name="name1">value</property>
@@ -361,7 +368,7 @@
       <appender-ref ref="name"/>
     </root>
   </loggers>
-</configuration>]]></source>
+</configuration>]]></pre>
           <p>
             See the many examples on this page for sample appender, filter and logger declarations.
           </p>
@@ -373,7 +380,8 @@
             instead of the ConsoleAppender being configuerd using an element named Console it is instead
             configured as an appender element with a type attribute containing "Console".
           </p>
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
+          <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>;
 <configuration>
   <properties>
     <property name="name1">value</property>
@@ -395,11 +403,12 @@
       <appender-ref ref="name"/>
     </root>
   </loggers>
-</configuration>]]></source>
+</configuration>]]></pre>
           <p>
             Below is a sample configuration using the strict format.
           </p>
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+          <pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="debug" strict="true" name="XMLConfigTest"
                packages="org.apache.logging.log4j.test">
   <properties>
@@ -448,7 +457,7 @@
     </root>
   </loggers>
 
-</configuration>]]></source>
+</configuration>]]></pre>
           <h4>Configuration with JSON</h4>
           <p>
             In addition to XML, Log4j can be configured using JSON. The JSON format is very similar to the
@@ -458,7 +467,8 @@
             plugins while the Console plugin will be assigned a value of STDOUT for its name attribute and the
             ThresholdFilter will be assigned a level of debug.
           </p>
-          <source>{ "configuration": { "status": "error", "name": "RoutingTest",
+          <pre class="prettyprint linenums">
+{ "configuration": { "status": "error", "name": "RoutingTest",
                      "packages": "org.apache.logging.log4j.test",
       "properties": {
         "property": { "name": "filename",
@@ -495,7 +505,7 @@
       "root": { "level": "error", "appender-ref": { "ref": "STDOUT" }}
     }
   }
-}</source>
+}</pre>
            <p>
             Note that in the RoutingAppender the Route element has been declared as an array. This is
             valid because each array element will be a Route component. This won't work for elements such as
@@ -504,7 +514,7 @@
             that contains the type of the appender. The following example illustrates this as well as how to
             declare multiple loggers as an array.
           </p>
-           <source>{ "configuration": { "status": "debug", "name": "RoutingTest",
+           <pre class="prettyprint linenums">{ "configuration": { "status": "debug", "name": "RoutingTest",
                       "packages": "org.apache.logging.log4j.test",
       "properties": {
         "property": { "name": "filename",
@@ -543,20 +553,22 @@
       "root": { "level": "error", "appender-ref": { "ref": "STDOUT" }}
     }
   }
-}</source>
+}</pre>
           <p>
             The JSON support uses Jackson to parse the JSON files. These dependencies must be added to a project
             that wants to use JSON for configuration:
-          <source><![CDATA[    <dependency>
-      <groupId>org.codehaus.jackson</groupId>
-      <artifactId>jackson-core-asl</artifactId>
-      <version>1.9.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.jackson</groupId>
-      <artifactId>jackson-mapper-asl</artifactId>
-      <version>1.9.2</version>
-    </dependency>]]></source>
+          <pre class="prettyprint linenums"><![CDATA[
+<dependency>
+  <groupId>org.codehaus.jackson</groupId>
+  <artifactId>jackson-core-asl</artifactId>
+  <version>1.9.2</version>
+</dependency>
+
+<dependency>
+  <groupId>org.codehaus.jackson</groupId>
+  <artifactId>jackson-mapper-asl</artifactId>
+  <version>1.9.2</version>
+</dependency>]]></pre>
           </p>
           <h4>Configuring loggers</h4>
           <p>
@@ -626,9 +638,8 @@
             allows any number of <code>filter</code> elements to be configured within it. The following example
             shows how multiple filters can be configured on the ConsoleAppender.
           </p>
-          <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="debug" name="XMLConfigTest"
-               packages="org.apache.logging.log4j.test">
+          <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<configuration status="debug" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
   <properties>
     <property name="filename">target/test.log</property>
   </properties>
@@ -677,7 +688,7 @@
     </root>
   </loggers>
 
-</configuration>]]></source>
+</configuration>]]></pre>
         </subsection>
         <a name="PropertySubstitution"/>
         <subsection name="Property Substitution">
@@ -692,9 +703,8 @@
             to be resolved using properties declared in the configuration itself. For example, the following example
             shows the filename for the rolling file appender being declared as a property.
           </p>
-<source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="debug" name="RoutingTest"
-               packages="org.apache.logging.log4j.test">
+<pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<configuration status="debug" name="RoutingTest" packages="org.apache.logging.log4j.test">
   <properties>
     <property name="filename">target/rolling1/rollingtest-${dollar}${dollar}{sd:type}.log</property>
   </properties>
@@ -734,7 +744,7 @@
     </root>
   </loggers>
 
-</configuration>]]></source>
+</configuration>]]></pre>
           <p>
             While this is useful, there are many more places properties can originate from. To accommodate this,
             Log4j also supports the syntax <code>${dollar}{prefix:name}</code> where the prefix identifies tells Log4j
@@ -790,13 +800,13 @@
             the variable declaration will be returned as the value. Default values may be declared in the configuration
             by doing:
           </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
+          <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration>
   <properties>
     <property name="type">Audit</property>
   </properties>
   ...
-</configuration>]]></source>
+</configuration>]]></pre>
           <p>
             <i>As a footnote, it is worth pointing out that the variables in the RollingFile appender declaration
             will also not be evaluated when the configuration is processed. This is simply because the resolution
@@ -813,9 +823,9 @@
             normal logging within appenders could create infinite recursion which Log4j will detect and cause
             the recursive events to be ignored. To accomodate this need, the Log4j 2 API includes a
             <a href="../log4j-api/apidocs/org/apache/logging/log4j/status/StatusLogger.html">StatusLogger</a>.
-            Components declare an instance of the StatusLogger similar to</p>
-<source>
-  protected final static Logger logger = StatusLogger.getLogger();</source>
+            Components declare an instance of the StatusLogger similar to:
+          </p>
+          <pre class="prettyprint">protected final static Logger logger = StatusLogger.getLogger();</pre>
           <p>
             Since StatusLogger implements the Log4j 2 API's Logger interface, all the normal Logger methods may
             be used.
@@ -825,7 +835,7 @@
             accomplished by adding the status attribute to the configuration element. The following
             configuration has the status attribute set to debug.
 
-<source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
+<pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
 <configuration status="debug" name="RoutingTest"
                packages="org.apache.logging.log4j.test">
   <properties>
@@ -867,143 +877,143 @@
     </root>
   </loggers>
 
-</configuration>]]></source>
+</configuration>]]></pre>
             During startup this configuration produces:
 #if ($isPDF)
-    <source>
- 2011-11-23 17:08:00,769 DEBUG Generated plugins in 0.003374000 seconds
- 2011-11-23 17:08:00,789 DEBUG Calling createProperty on class org.apache.logging.log4j.core.
-        config.Property for element property with params(name="filename",
-        value="target/rolling1/rollingtest-${dollar}{sd:type}.log")
- 2011-11-23 17:08:00,792 DEBUG Calling configureSubstitutor on class org.apache.logging.log4j.
-        core.config.plugins.PropertiesPlugin for element properties with
-        params(properties={filename=target/rolling1/rollingtest-${dollar}{sd:type}.log})
- 2011-11-23 17:08:00,794 DEBUG Generated plugins in 0.001362000 seconds
- 2011-11-23 17:08:00,797 DEBUG Calling createFilter on class org.apache.logging.log4j.core.
-        filter.ThresholdFilter for element ThresholdFilter with params(level="debug",
-        onMatch="null", onMismatch="null")
- 2011-11-23 17:08:00,800 DEBUG Calling createLayout on class org.apache.logging.log4j.core.
-        layout.PatternLayout for element PatternLayout with params(pattern="%m%n",
-        Configuration(RoutingTest), null, charset="null")
- 2011-11-23 17:08:00,802 DEBUG Generated plugins in 0.001349000 seconds
- 2011-11-23 17:08:00,804 DEBUG Calling createAppender on class org.apache.logging.log4j.core.
-        appender.ConsoleAppender for element Console with params(PatternLayout(%m%n), null,
-        target="null", name="STDOUT", suppressExceptions="null")
- 2011-11-23 17:08:00,804 DEBUG Calling createFilter on class org.apache.logging.log4j.core.
-        filter.ThresholdFilter for element ThresholdFilter with params(level="debug",
-        onMatch="null", onMismatch="null")
- 2011-11-23 17:08:00,806 DEBUG Calling createAppender on class org.apache.logging.log4j.test.
-        appender.ListAppender for element List with params(name="List", entryPerNewLine="null",
-        raw="null", null, ThresholdFilter(DEBUG))
- 2011-11-23 17:08:00,813 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.
-        routing.Route for element Route with params(appender-ref="null", key="null", Node=Route)
- 2011-11-23 17:08:00,823 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.
-        routing.Route for element Route with params(appender-ref="STDOUT", key="Audit", Node=Route)
- 2011-11-23 17:08:00,824 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.
-        routing.Route for element Route with params(appender-ref="List", key="Service", Node=Route)
- 2011-11-23 17:08:00,825 DEBUG Calling createRoutes on class org.apache.logging.log4j.core.appender.
-        routing.Routes for element Routes with params(pattern="${dollar}{sd:type}",
-        routes={Route(type=dynamic default), Route(type=static Reference=STDOUT key='Audit'),
-        Route(type=static Reference=List key='Service')})
- 2011-11-23 17:08:00,827 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.
-        routing.RoutingAppender for element Routing with params(name="Routing",
-        suppressExceptions="null", Routes({Route(type=dynamic default),Route(type=static
-        Reference=STDOUT key='Audit'),
-        Route(type=static Reference=List key='Service')}), Configuration(RoutingTest), null, null)
- 2011-11-23 17:08:00,827 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.
-        plugins.AppendersPlugin for element appenders with params(appenders={STDOUT, List, Routing})
- 2011-11-23 17:08:00,828 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.
-        config.plugins.AppenderRefPlugin for element appender-ref with params(ref="Routing")
- 2011-11-23 17:08:00,829 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.
-        LoggerConfig for element logger with params(additivity="false", level="info", name="EventLogger",
-        appender-ref={Routing}, null)
- 2011-11-23 17:08:00,830 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.
-        config.plugins.AppenderRefPlugin for element appender-ref with params(ref="STDOUT")</source>
-             <source>
- 2011-11-23 17:08:00,831 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.
-        LoggerConfig$RootLogger for element root with params(additivity="null", level="error",
-        appender-ref={STDOUT}, null)
- 2011-11-23 17:08:00,833 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.
-        config.plugins.LoggersPlugin for element loggers with params(loggers={EventLogger, root})
- 2011-11-23 17:08:00,834 DEBUG Reconfiguration completed
- 2011-11-23 17:08:00,846 DEBUG Calling createLayout on class org.apache.logging.log4j.core.
-        layout.PatternLayout for element PatternLayout with params(pattern="%d %p %C{1.} [%t] %m%n",
-        Configuration(RoutingTest), null, charset="null")
- 2011-11-23 17:08:00,849 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.
-        appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with
-        params(size="500")
- 2011-11-23 17:08:00,851 DEBUG Calling createAppender on class org.apache.logging.log4j.core.
-        appender.RollingFileAppender for element RollingFile with
-        params(fileName="target/rolling1/rollingtest-Unknown.log",
-        filePattern="target/rolling1/test1-Unknown.%i.log.gz", append="null", name="Rolling-Unknown",
-        bufferedIO="null", immediateFlush="null",
-        SizeBasedTriggeringPolicy(SizeBasedTriggeringPolicy(size=500)), null,
-        PatternLayout(%d %p %C{1.} [%t] %m%n), null, suppressExceptions="null")
- 2011-11-23 17:08:00,858 DEBUG Generated plugins in 0.002014000 seconds
- 2011-11-23 17:08:00,889 DEBUG Reconfiguration started for context sun.misc.
-        Launcher$AppClassLoader@37b90b39
- 2011-11-23 17:08:00,890 DEBUG Generated plugins in 0.001355000 seconds
- 2011-11-23 17:08:00,959 DEBUG Generated plugins in 0.001239000 seconds
- 2011-11-23 17:08:00,961 DEBUG Generated plugins in 0.001197000 seconds
- 2011-11-23 17:08:00,965 WARN No Loggers were configured, using default
- 2011-11-23 17:08:00,976 DEBUG Reconfiguration completed</source>
+    <pre>
+2011-11-23 17:08:00,769 DEBUG Generated plugins in 0.003374000 seconds
+2011-11-23 17:08:00,789 DEBUG Calling createProperty on class org.apache.logging.log4j.core.
+       config.Property for element property with params(name="filename",
+       value="target/rolling1/rollingtest-${dollar}{sd:type}.log")
+2011-11-23 17:08:00,792 DEBUG Calling configureSubstitutor on class org.apache.logging.log4j.
+       core.config.plugins.PropertiesPlugin for element properties with
+       params(properties={filename=target/rolling1/rollingtest-${dollar}{sd:type}.log})
+2011-11-23 17:08:00,794 DEBUG Generated plugins in 0.001362000 seconds
+2011-11-23 17:08:00,797 DEBUG Calling createFilter on class org.apache.logging.log4j.core.
+       filter.ThresholdFilter for element ThresholdFilter with params(level="debug",
+       onMatch="null", onMismatch="null")
+2011-11-23 17:08:00,800 DEBUG Calling createLayout on class org.apache.logging.log4j.core.
+       layout.PatternLayout for element PatternLayout with params(pattern="%m%n",
+       Configuration(RoutingTest), null, charset="null")
+2011-11-23 17:08:00,802 DEBUG Generated plugins in 0.001349000 seconds
+2011-11-23 17:08:00,804 DEBUG Calling createAppender on class org.apache.logging.log4j.core.
+       appender.ConsoleAppender for element Console with params(PatternLayout(%m%n), null,
+       target="null", name="STDOUT", suppressExceptions="null")
+2011-11-23 17:08:00,804 DEBUG Calling createFilter on class org.apache.logging.log4j.core.
+       filter.ThresholdFilter for element ThresholdFilter with params(level="debug",
+       onMatch="null", onMismatch="null")
+2011-11-23 17:08:00,806 DEBUG Calling createAppender on class org.apache.logging.log4j.test.
+       appender.ListAppender for element List with params(name="List", entryPerNewLine="null",
+       raw="null", null, ThresholdFilter(DEBUG))
+2011-11-23 17:08:00,813 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.
+       routing.Route for element Route with params(appender-ref="null", key="null", Node=Route)
+2011-11-23 17:08:00,823 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.
+       routing.Route for element Route with params(appender-ref="STDOUT", key="Audit", Node=Route)
+2011-11-23 17:08:00,824 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.
+       routing.Route for element Route with params(appender-ref="List", key="Service", Node=Route)
+2011-11-23 17:08:00,825 DEBUG Calling createRoutes on class org.apache.logging.log4j.core.appender.
+       routing.Routes for element Routes with params(pattern="${dollar}{sd:type}",
+       routes={Route(type=dynamic default), Route(type=static Reference=STDOUT key='Audit'),
+       Route(type=static Reference=List key='Service')})
+2011-11-23 17:08:00,827 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.
+       routing.RoutingAppender for element Routing with params(name="Routing",
+       suppressExceptions="null", Routes({Route(type=dynamic default),Route(type=static
+       Reference=STDOUT key='Audit'),
+       Route(type=static Reference=List key='Service')}), Configuration(RoutingTest), null, null)
+2011-11-23 17:08:00,827 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.
+       plugins.AppendersPlugin for element appenders with params(appenders={STDOUT, List, Routing})
+2011-11-23 17:08:00,828 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.
+       config.plugins.AppenderRefPlugin for element appender-ref with params(ref="Routing")
+2011-11-23 17:08:00,829 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.
+       LoggerConfig for element logger with params(additivity="false", level="info", name="EventLogger",
+       appender-ref={Routing}, null)
+2011-11-23 17:08:00,830 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.
+       config.plugins.AppenderRefPlugin for element appender-ref with params(ref="STDOUT")</pre>
+            <pre class="prettyprint linenums">
+2011-11-23 17:08:00,831 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.
+       LoggerConfig$RootLogger for element root with params(additivity="null", level="error",
+       appender-ref={STDOUT}, null)
+2011-11-23 17:08:00,833 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.
+       config.plugins.LoggersPlugin for element loggers with params(loggers={EventLogger, root})
+2011-11-23 17:08:00,834 DEBUG Reconfiguration completed
+2011-11-23 17:08:00,846 DEBUG Calling createLayout on class org.apache.logging.log4j.core.
+       layout.PatternLayout for element PatternLayout with params(pattern="%d %p %C{1.} [%t] %m%n",
+       Configuration(RoutingTest), null, charset="null")
+2011-11-23 17:08:00,849 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.
+       appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with
+       params(size="500")
+2011-11-23 17:08:00,851 DEBUG Calling createAppender on class org.apache.logging.log4j.core.
+       appender.RollingFileAppender for element RollingFile with
+       params(fileName="target/rolling1/rollingtest-Unknown.log",
+       filePattern="target/rolling1/test1-Unknown.%i.log.gz", append="null", name="Rolling-Unknown",
+       bufferedIO="null", immediateFlush="null",
+       SizeBasedTriggeringPolicy(SizeBasedTriggeringPolicy(size=500)), null,
+       PatternLayout(%d %p %C{1.} [%t] %m%n), null, suppressExceptions="null")
+2011-11-23 17:08:00,858 DEBUG Generated plugins in 0.002014000 seconds
+2011-11-23 17:08:00,889 DEBUG Reconfiguration started for context sun.misc.
+       Launcher$AppClassLoader@37b90b39
+2011-11-23 17:08:00,890 DEBUG Generated plugins in 0.001355000 seconds
+2011-11-23 17:08:00,959 DEBUG Generated plugins in 0.001239000 seconds
+2011-11-23 17:08:00,961 DEBUG Generated plugins in 0.001197000 seconds
+2011-11-23 17:08:00,965 WARN No Loggers were configured, using default
+2011-11-23 17:08:00,976 DEBUG Reconfiguration completed</pre>
 #else
-             <source>
- 2011-11-23 17:08:00,769 DEBUG Generated plugins in 0.003374000 seconds
- 2011-11-23 17:08:00,789 DEBUG Calling createProperty on class org.apache.logging.log4j.core.config.Property for element property with params(name="filename", value="target/rolling1/rollingtest-${dollar}{sd:type}.log")
- 2011-11-23 17:08:00,792 DEBUG Calling configureSubstitutor on class org.apache.logging.log4j.core.config.plugins.PropertiesPlugin for element properties with params(properties={filename=target/rolling1/rollingtest-${dollar}{sd:type}.log})
- 2011-11-23 17:08:00,794 DEBUG Generated plugins in 0.001362000 seconds
- 2011-11-23 17:08:00,797 DEBUG Calling createFilter on class org.apache.logging.log4j.core.filter.ThresholdFilter for element ThresholdFilter with params(level="debug", onMatch="null", onMismatch="null")
- 2011-11-23 17:08:00,800 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%m%n", Configuration(RoutingTest), null, charset="null")
- 2011-11-23 17:08:00,802 DEBUG Generated plugins in 0.001349000 seconds
- 2011-11-23 17:08:00,804 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%m%n), null, target="null", name="STDOUT", suppressExceptions="null")
- 2011-11-23 17:08:00,804 DEBUG Calling createFilter on class org.apache.logging.log4j.core.filter.ThresholdFilter for element ThresholdFilter with params(level="debug", onMatch="null", onMismatch="null")
- 2011-11-23 17:08:00,806 DEBUG Calling createAppender on class org.apache.logging.log4j.test.appender.ListAppender for element List with params(name="List", entryPerNewLine="null", raw="null", null, ThresholdFilter(DEBUG))
- 2011-11-23 17:08:00,813 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="null", key="null", Node=Route)
- 2011-11-23 17:08:00,823 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="STDOUT", key="Audit", Node=Route)
- 2011-11-23 17:08:00,824 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="List", key="Service", Node=Route)
- 2011-11-23 17:08:00,825 DEBUG Calling createRoutes on class org.apache.logging.log4j.core.appender.routing.Routes for element Routes with params(pattern="${dollar}{sd:type}", routes={Route(type=dynamic default), Route(type=static Reference=STDOUT key='Audit'), Route(type=static Reference=List key='Service')})
- 2011-11-23 17:08:00,827 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.routing.RoutingAppender for element Routing with params(name="Routing", suppressExceptions="null", Routes({Route(type=dynamic default),Route(type=static Reference=STDOUT key='Audit'),Route(type=static Reference=List key='Service')}), Configuration(RoutingTest), null, null)
- 2011-11-23 17:08:00,827 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={STDOUT, List, Routing})
- 2011-11-23 17:08:00,828 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.plugins.AppenderRefPlugin for element appender-ref with params(ref="Routing")
- 2011-11-23 17:08:00,829 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="false", level="info", name="EventLogger", appender-ref={Routing}, null)
- 2011-11-23 17:08:00,830 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.plugins.AppenderRefPlugin for element appender-ref with params(ref="STDOUT")
- 2011-11-23 17:08:00,831 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="error", appender-ref={STDOUT}, null)
- 2011-11-23 17:08:00,833 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={EventLogger, root})
- 2011-11-23 17:08:00,834 DEBUG Reconfiguration completed
- 2011-11-23 17:08:00,846 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d %p %C{1.} [%t] %m%n", Configuration(RoutingTest), null, charset="null")
- 2011-11-23 17:08:00,849 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with params(size="500")
- 2011-11-23 17:08:00,851 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile with params(fileName="target/rolling1/rollingtest-Unknown.log", filePattern="target/rolling1/test1-Unknown.%i.log.gz", append="null", name="Rolling-Unknown", bufferedIO="null", immediateFlush="null", SizeBasedTriggeringPolicy(SizeBasedTriggeringPolicy(size=500)), null, PatternLayout(%d %p %C{1.} [%t] %m%n), null, suppressExceptions="null")
- 2011-11-23 17:08:00,858 DEBUG Generated plugins in 0.002014000 seconds
- 2011-11-23 17:08:00,889 DEBUG Reconfiguration started for context sun.misc.Launcher$AppClassLoader@37b90b39
- 2011-11-23 17:08:00,890 DEBUG Generated plugins in 0.001355000 seconds
- 2011-11-23 17:08:00,959 DEBUG Generated plugins in 0.001239000 seconds
- 2011-11-23 17:08:00,961 DEBUG Generated plugins in 0.001197000 seconds
- 2011-11-23 17:08:00,965 WARN No Loggers were configured, using default
- 2011-11-23 17:08:00,976 DEBUG Reconfiguration completed</source>
+<pre>
+2011-11-23 17:08:00,769 DEBUG Generated plugins in 0.003374000 seconds
+2011-11-23 17:08:00,789 DEBUG Calling createProperty on class org.apache.logging.log4j.core.config.Property for element property with params(name="filename", value="target/rolling1/rollingtest-${dollar}{sd:type}.log")
+2011-11-23 17:08:00,792 DEBUG Calling configureSubstitutor on class org.apache.logging.log4j.core.config.plugins.PropertiesPlugin for element properties with params(properties={filename=target/rolling1/rollingtest-${dollar}{sd:type}.log})
+2011-11-23 17:08:00,794 DEBUG Generated plugins in 0.001362000 seconds
+2011-11-23 17:08:00,797 DEBUG Calling createFilter on class org.apache.logging.log4j.core.filter.ThresholdFilter for element ThresholdFilter with params(level="debug", onMatch="null", onMismatch="null")
+2011-11-23 17:08:00,800 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%m%n", Configuration(RoutingTest), null, charset="null")
+2011-11-23 17:08:00,802 DEBUG Generated plugins in 0.001349000 seconds
+2011-11-23 17:08:00,804 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%m%n), null, target="null", name="STDOUT", suppressExceptions="null")
+2011-11-23 17:08:00,804 DEBUG Calling createFilter on class org.apache.logging.log4j.core.filter.ThresholdFilter for element ThresholdFilter with params(level="debug", onMatch="null", onMismatch="null")
+2011-11-23 17:08:00,806 DEBUG Calling createAppender on class org.apache.logging.log4j.test.appender.ListAppender for element List with params(name="List", entryPerNewLine="null", raw="null", null, ThresholdFilter(DEBUG))
+2011-11-23 17:08:00,813 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="null", key="null", Node=Route)
+2011-11-23 17:08:00,823 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="STDOUT", key="Audit", Node=Route)
+2011-11-23 17:08:00,824 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="List", key="Service", Node=Route)
+2011-11-23 17:08:00,825 DEBUG Calling createRoutes on class org.apache.logging.log4j.core.appender.routing.Routes for element Routes with params(pattern="${dollar}{sd:type}", routes={Route(type=dynamic default), Route(type=static Reference=STDOUT key='Audit'), Route(type=static Reference=List key='Service')})
+2011-11-23 17:08:00,827 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.routing.RoutingAppender for element Routing with params(name="Routing", suppressExceptions="null", Routes({Route(type=dynamic default),Route(type=static Reference=STDOUT key='Audit'),Route(type=static Reference=List key='Service')}), Configuration(RoutingTest), null, null)
+2011-11-23 17:08:00,827 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={STDOUT, List, Routing})
+2011-11-23 17:08:00,828 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.plugins.AppenderRefPlugin for element appender-ref with params(ref="Routing")
+2011-11-23 17:08:00,829 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="false", level="info", name="EventLogger", appender-ref={Routing}, null)
+2011-11-23 17:08:00,830 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.plugins.AppenderRefPlugin for element appender-ref with params(ref="STDOUT")
+2011-11-23 17:08:00,831 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="error", appender-ref={STDOUT}, null)
+2011-11-23 17:08:00,833 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={EventLogger, root})
+2011-11-23 17:08:00,834 DEBUG Reconfiguration completed
+2011-11-23 17:08:00,846 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d %p %C{1.} [%t] %m%n", Configuration(RoutingTest), null, charset="null")
+2011-11-23 17:08:00,849 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with params(size="500")
+2011-11-23 17:08:00,851 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile with params(fileName="target/rolling1/rollingtest-Unknown.log", filePattern="target/rolling1/test1-Unknown.%i.log.gz", append="null", name="Rolling-Unknown", bufferedIO="null", immediateFlush="null", SizeBasedTriggeringPolicy(SizeBasedTriggeringPolicy(size=500)), null, PatternLayout(%d %p %C{1.} [%t] %m%n), null, suppressExceptions="null")
+2011-11-23 17:08:00,858 DEBUG Generated plugins in 0.002014000 seconds
+2011-11-23 17:08:00,889 DEBUG Reconfiguration started for context sun.misc.Launcher$AppClassLoader@37b90b39
+2011-11-23 17:08:00,890 DEBUG Generated plugins in 0.001355000 seconds
+2011-11-23 17:08:00,959 DEBUG Generated plugins in 0.001239000 seconds
+2011-11-23 17:08:00,961 DEBUG Generated plugins in 0.001197000 seconds
+2011-11-23 17:08:00,965 WARN No Loggers were configured, using default
+2011-11-23 17:08:00,976 DEBUG Reconfiguration completed</pre>
 #end
           </p>
           <p>
             If the status attribute is set to error than only error messages will be written to the console. This
             makes troubleshooting configuration errors possible. As an example, if the configuration above is changed
             to have the status set to error and the logger declaration is:</p>
-<source><![CDATA[  <logger name="EventLogger" level="info" additivity="false">
-    <appender-ref ref="Routng"/>
-  </logger>]]></source>
+<pre class="prettyprint linenums"><![CDATA[<logger name="EventLogger" level="info" additivity="false">
+  <appender-ref ref="Routng"/>
+</logger>]]></pre>
           <p>
             the following error message will be produced.
-<source>
- 2011-11-24 23:21:25,517 ERROR Unable to locate appender Routng for logger EventLogger</source>
+            <pre class="prettyprint linenums">
+2011-11-24 23:21:25,517 ERROR Unable to locate appender Routng for logger EventLogger</pre>
           </p>
           <p>
             Applications may wish to direct the status output to some other destination. This can be accomplished
             by setting the dest attribute to either "err" to send the output to stderr or to a file location or URL.
             This can also be done by insuring the configured status is set to OFF and then configuring the application
             programmatically such as:
-<source>
-  StatusConsoleListener listener = new StatusConsoleListener(Level.ERROR);
-  ((StatusLogger) logger).registerListener(listener);
-</source>
+<pre class="prettyprint linenums">
+StatusConsoleListener listener = new StatusConsoleListener(Level.ERROR);
+((StatusLogger) logger).registerListener(listener);
+</pre>
           </p>
         </subsection>
         <a name="UnitTestingInMaven"/>

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/eventlogging.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/eventlogging.xml?rev=1410726&r1=1410725&r2=1410726&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/eventlogging.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/eventlogging.xml Sat Nov 17 13:11:44 2012
@@ -39,97 +39,99 @@
               recorded occurs a StructuredDataMessage should be created and populated.
               Then call EventLogger.logEvent(msg) where msg is a reference to the StructuredDataMessage.</p>
 
-            <source>    import org.apache.logging.log4j.ThreadContext;
-    import org.apache.commons.lang.time.DateUtils;
-
-    import javax.servlet.Filter;
-    import javax.servlet.FilterConfig;
-    import javax.servlet.ServletException;
-    import javax.servlet.ServletRequest;
-    import javax.servlet.ServletResponse;
-    import javax.servlet.FilterChain;
-    import javax.servlet.http.HttpSession;
-    import javax.servlet.http.HttpServletRequest;
-    import javax.servlet.http.Cookie;
-    import javax.servlet.http.HttpServletResponse;
-    import java.io.IOException;
-    import java.util.TimeZone;
-
-    public class RequestFilter implements Filter {
-        private FilterConfig filterConfig;
-        private static String TZ_NAME = "timezoneOffset";
-
-        public void init(FilterConfig filterConfig) throws ServletException {
-            this.filterConfig = filterConfig;
-        }
-
-        /**
-         * Sample filter that populates the MDC on every request.
-         */
-        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
-                throws IOException, ServletException {
-            HttpServletRequest request = (HttpServletRequest)servletRequest;
-            HttpServletResponse response = (HttpServletResponse)servletResponse;
-            ThreadContext.put("ipAddress", request.getRemoteAddr());
-            HttpSession session = request.getSession(false);
-            TimeZone timeZone = null;
-            if (session != null) {
-                // Something should set this after authentication completes
-                String loginId = (String)session.getAttribute("LoginId");
-                if (loginId != null) {
-                    ThreadContext.put("loginId", loginId);
-                }
-                // This assumes there is some javascript on the user's page to create the cookie.
-                if (session.getAttribute(TZ_NAME) == null) {
-                    if (request.getCookies() != null) {
-                        for (Cookie cookie : request.getCookies()) {
-                            if (TZ_NAME.equals(cookie.getName())) {
-                                int tzOffsetMinutes = Integer.parseInt(cookie.getValue());
-                                timeZone = TimeZone.getTimeZone("GMT");
-                                timeZone.setRawOffset((int)(tzOffsetMinutes * DateUtils.MILLIS_PER_MINUTE));
-                                request.getSession().setAttribute(TZ_NAME, tzOffsetMinutes);
-                                cookie.setMaxAge(0);
-                                response.addCookie(cookie);
-                            }
+            <pre class="prettyprint linenums">
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.commons.lang.time.DateUtils;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.TimeZone;
+
+public class RequestFilter implements Filter {
+    private FilterConfig filterConfig;
+    private static String TZ_NAME = "timezoneOffset";
+
+    public void init(FilterConfig filterConfig) throws ServletException {
+        this.filterConfig = filterConfig;
+    }
+
+    /**
+     * Sample filter that populates the MDC on every request.
+     */
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+            throws IOException, ServletException {
+        HttpServletRequest request = (HttpServletRequest)servletRequest;
+        HttpServletResponse response = (HttpServletResponse)servletResponse;
+        ThreadContext.put("ipAddress", request.getRemoteAddr());
+        HttpSession session = request.getSession(false);
+        TimeZone timeZone = null;
+        if (session != null) {
+            // Something should set this after authentication completes
+            String loginId = (String)session.getAttribute("LoginId");
+            if (loginId != null) {
+                ThreadContext.put("loginId", loginId);
+            }
+            // This assumes there is some javascript on the user's page to create the cookie.
+            if (session.getAttribute(TZ_NAME) == null) {
+                if (request.getCookies() != null) {
+                    for (Cookie cookie : request.getCookies()) {
+                        if (TZ_NAME.equals(cookie.getName())) {
+                            int tzOffsetMinutes = Integer.parseInt(cookie.getValue());
+                            timeZone = TimeZone.getTimeZone("GMT");
+                            timeZone.setRawOffset((int)(tzOffsetMinutes * DateUtils.MILLIS_PER_MINUTE));
+                            request.getSession().setAttribute(TZ_NAME, tzOffsetMinutes);
+                            cookie.setMaxAge(0);
+                            response.addCookie(cookie);
                         }
                     }
                 }
             }
-            ThreadContext.put("hostname", servletRequest.getServerName());
-            ThreadContext.put("productName", filterConfig.getInitParameter("ProductName"));
-            Threadcontext.put("locale", servletRequest.getLocale().getDisplayName());
-            if (timeZone == null) {
-                timeZone = TimeZone.getDefault();
-            }
-            ThreadContext.put("timezone", timeZone.getDisplayName());
-            filterChain.doFilter(servletRequest, servletResponse);
-            ThreadContext.clear();
         }
-
-        public void destroy() {
+        ThreadContext.put("hostname", servletRequest.getServerName());
+        ThreadContext.put("productName", filterConfig.getInitParameter("ProductName"));
+        Threadcontext.put("locale", servletRequest.getLocale().getDisplayName());
+        if (timeZone == null) {
+            timeZone = TimeZone.getDefault();
         }
-    }</source>
+        ThreadContext.put("timezone", timeZone.getDisplayName());
+        filterChain.doFilter(servletRequest, servletResponse);
+        ThreadContext.clear();
+    }
+
+    public void destroy() {
+    }
+}</pre>
             <p>Sample class that uses EventLogger.</p>
-            <source>    import org.apache.logging.log4j.StructuredDataMessage;
-    import org.apache.logging.log4j.EventLogger;
-
-    import java.util.Date;
-    import java.util.UUID;
-
-    public class MyApp {
-
-        public String doFundsTransfer(Account toAccount, Account fromAccount, long amount) {
-            toAccount.deposit(amount);
-            fromAccount.withdraw(amount);
-            String confirm = UUID.randomUUID().toString();
-            StructuredDataMessage msg = new StructureDataMessage(confirm, null, "transfer");
-            msg.put("toAccount", toAccount);
-            msg.put("fromAccount", fromAccount);
-            msg.put("amount", amount);
-            EventLogger.logEvent(data);
-            return confirm;
-        }
-    }</source>
+            <pre class="prettyprint linenums">
+import org.apache.logging.log4j.StructuredDataMessage;
+import org.apache.logging.log4j.EventLogger;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class MyApp {
+
+    public String doFundsTransfer(Account toAccount, Account fromAccount, long amount) {
+        toAccount.deposit(amount);
+        fromAccount.withdraw(amount);
+        String confirm = UUID.randomUUID().toString();
+        StructuredDataMessage msg = new StructureDataMessage(confirm, null, "transfer");
+        msg.put("toAccount", toAccount);
+        msg.put("fromAccount", fromAccount);
+        msg.put("amount", amount);
+        EventLogger.logEvent(data);
+        return confirm;
+    }
+}</pre>
             <p>The EventLogger class uses a Logger named "EventLogger". EventLogger uses a logging level
               of OFF as the default to indicate that it cannot be filtered. These events can be
               formatted for printing using the

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/extending.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/extending.xml?rev=1410726&r1=1410725&r2=1410726&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/extending.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/extending.xml Sat Nov 17 13:11:44 2012
@@ -96,7 +96,7 @@
               PluginType of the node and a List of all of its child Nodes. BaseConfiguration will then be
               passed the Node tree and instantiate the configuration objects from that.
             </p>
-            <source>
+            <pre class="prettyprint linenums">
 @Plugin(name = "XMLConfigurationFactory", type = "ConfigurationFactory")
 @Order(5)
 public class XMLConfigurationFactory extends ConfigurationFactory {
@@ -122,7 +122,7 @@ public class XMLConfigurationFactory ext
     public String[] getSupportedTypes() {
         return SUFFIXES;
     }
-}</source>
+}</pre>
           </subsection>
           <subsection name="LoggerConfig">
             <p>
@@ -136,7 +136,7 @@ public class XMLConfigurationFactory ext
             <p>
               The following example shows how the root LoggerConfig simply extends a generic LoggerConfig.
             </p>
-            <source><![CDATA[
+            <pre class="prettyprint linenums"><![CDATA[
 @Plugin(name = "root", type = "Core", printObject = true)
 public static class RootLogger extends LoggerConfig {
 
@@ -157,7 +157,7 @@ public static class RootLogger extends L
 
         return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, level, additive);
     }
-}]]></source>
+}]]></pre>
           </subsection>
           <subsection name="Lookups">
             <p>
@@ -172,7 +172,7 @@ public static class RootLogger extends L
               use a PluginFactory. Instead, they are required to provide a constructor that accepts no arguments.
               The example below shows a Lookup that will return the value of a System Property.
             </p>
-            <source>
+            <pre class="prettyprint linenums">
 @Plugin(name = "sys", type = "Lookup")
 public class SystemPropertiesLookup implements StrLookup {
 
@@ -194,7 +194,7 @@ public class SystemPropertiesLookup impl
     public String lookup(LogEvent event, String key) {
         return System.getProperty(key);
     }
-}</source>
+}</pre>
           </subsection>
           <subsection name="Filters">
             <p>
@@ -210,7 +210,7 @@ public class SystemPropertiesLookup impl
               The example below shows a Filter used to reject LogEvents based upon their logging level. Notice the
               typical pattern where all the filter methods resolve to a single filter method.
             </p>
-            <source>
+            <pre class="prettyprint linenums">
 @Plugin(name = "ThresholdFilter", type = "Core", elementType = "filter", printObject = true)
 public final class ThresholdFilter extends FilterBase {
 
@@ -264,7 +264,7 @@ public final class ThresholdFilter exten
 
         return new ThresholdFilter(level, onMatch, onMismatch);
     }
-}</source>
+}</pre>
           </subsection>
           <subsection name="Appenders">
             <p>
@@ -286,7 +286,7 @@ public final class ThresholdFilter exten
               new one. This insures that events are not lost while a reconfiguration is taking place without
               requiring that logging pause while the reconfiguration takes place.
             </p>
-            <source>
+            <pre class="prettyprint linenums">
 @Plugin(name = "Stub", type = "Core", elementType = "appender", printObject = true)
 public final class StubAppender extends OutputStreamAppender {
 
@@ -316,7 +316,7 @@ public final class StubAppender extends 
         }
         return new StubAppender(name, layout, filter, manager, handleExceptions);
     }
-}</source>
+}</pre>
           </subsection>
           <subsection name="Layouts">
             <p>
@@ -333,7 +333,7 @@ public final class StubAppender extends 
               The plugin also must provide a static method annotated as a PluginFactory and with each of the
               methods parameters annotated with PluginAttr or PluginElement as appropriate.
             </p>
-            <source>
+            <pre class="prettyprint linenums">
 @Plugin(name = "SampleLayout", type = "Core", elementType = "layout", printObject = true)
 public class SampleLayout extends AbstractStringLayout {
 
@@ -361,7 +361,7 @@ public class SampleLayout extends Abstra
         boolean comp = complete == null ? false : Boolean.valueOf(complete);
         return new SampleLayout(info, props, comp, c);
     }
-}</source>
+}</pre>
           </subsection>
           <subsection name="PatternConverters">
             <p>
@@ -385,7 +385,7 @@ public class SampleLayout extends Abstra
             <p>
               The following shows the skeleton of a Converter plugin.
             </p>
-            <source>
+            <pre class="prettyprint linenums">
 @Plugin(name = "query", type = "Converter")
 @ConverterKeys({"q", "query"})
 public final class QueryConverter extends LogEventPatternConverter {
@@ -396,7 +396,7 @@ public final class QueryConverter extend
     public static QueryConverter newInstance(final String[] options) {
       return new QueryConverter(options);
     }
-}</source>
+}</pre>
           </subsection>
           <subsection name="Custom Plugins">
 

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/filters.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/filters.xml?rev=1410726&r1=1410725&r2=1410726&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/filters.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/filters.xml Sat Nov 17 13:11:44 2012
@@ -53,7 +53,7 @@
             The BurstFilter provides a mechanism to control the rate at which LogEvents are processed by
             silently discarding events after the maximum limit has been reached.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -95,7 +95,7 @@
            <p>
             A configuration containing the BurstFilter might look like:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -112,8 +112,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="CompositeFilter"/>
@@ -126,7 +125,7 @@
            <p>
             A configuration containing the CompositeFilter might look like:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <filters>
     <Marker marker="EVENT" onMatch="ACCEPT" onMismatch="NETURAL"/>
@@ -158,8 +157,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="DynamicThresholdFilter"/>
@@ -169,7 +167,7 @@
             if the user's loginid is being captured in the ThreadContext Map then it is possible to enable
             debug logging for only that user.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -204,7 +202,7 @@
            <p>
             Here is a sample configuration containing the DynamicThresholdFilter:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
     <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR"
                             onMatch="ACCEPT" onMismatch="NEUTRAL">
@@ -225,8 +223,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="MapFilter"/>
@@ -234,7 +231,7 @@
           <p>
             The MapFilter allows filtering against data elements that are in a MapMessage.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -269,7 +266,7 @@
            <p>
             As in this configuration, the MapFilter can be used to log particular events:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <MapFilter onMatch="ACCEPT" onMismatch="NEUTRAL" operator="or">
     <KeyValuePair key="eventId" value="Login"/>
@@ -290,14 +287,13 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
           <p>
             This sample configuration will exhibit the same behavior as the preceding example since the only
           logger configured is the root.
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -319,14 +315,13 @@
       </appender-ref>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
           <p>
             This third sample configuration will exhibit the same behavior as the preceding examples since the only
             logger configured is the root and the root is only configured with a single appender reference.
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -348,8 +343,7 @@
       </appender-ref>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="MarkerFilter"/>
@@ -359,7 +353,7 @@
             in the LogEvent. A match occurs when the Marker name matches either the Log Event's Marker
             or one of its parents.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -388,7 +382,7 @@
            <p>
              A sample configuration that only allows the event to be written by the appender if the Marker matches:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -405,8 +399,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="RegexFilter"/>
@@ -414,7 +407,7 @@
            <p>
             The RegexFilter allows the formatted or unformatted message to be compared against a regular expression.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -449,7 +442,7 @@
            <p>
              A sample configuration that only allows the event to be written by the appender if it contains the word "test":
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -466,8 +459,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="StructuredDataFilter"/>
@@ -475,7 +467,7 @@
           <p>
             The StructuredDataFilter is a MapFilter that also allows filtering on the event id, type and message.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -513,7 +505,7 @@
            <p>
             As in this configuration, the StructuredDataFilter can be used to log particular events:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <StructuredDataFilter onMatch="ACCEPT" onMismatch="NEUTRAL" operator="or">
     <KeyValuePair key="id" value="Login"/>
@@ -534,8 +526,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="ThreadContextMapFilter"/>
@@ -543,7 +534,7 @@
           <p>
             The ThreadContextMapFilter allows filtering against data elements that are in the ThreadContext Map.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -578,7 +569,7 @@
            <p>
             A configuration containing the ThreadContextMapFilter might look like:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR"
                           onMatch="ACCEPT" onMismatch="NEUTRAL">
@@ -599,8 +590,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="ThresholdFilter"/>
@@ -611,7 +601,7 @@
             is configured with Level ERROR and the LogEvent contains Level DEBUG then the onMismatch value will
             be returned since ERROR events are more specific than DEBUG.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -640,7 +630,7 @@
            <p>
              A sample configuration that only allows the event to be written by the appender if the level matches:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -657,8 +647,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
         <a name="TimeFilter"/>
@@ -666,7 +655,7 @@
            <p>
             The time filter can be used to restrict filter to only a certain portion of the day.
           </p>
-          <table border="1" width="100%">
+          <table>
             <tr>
               <th>Parameter Name</th>
               <th>Type</th>
@@ -711,7 +700,7 @@
              A sample configuration that only allows the event to be written by the appender from 5:00 to 5:30 am each
              day using the default timezone:
 
-            <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+            <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="warn" name="MyApp" packages="">
   <appenders>
     <RollingFile name="RollingFile" fileName="logs/app.log"
@@ -728,8 +717,7 @@
       <appender-ref ref="RollingFile"/>
     </root>
   </loggers>
-</configuration>
-  ]]></source>
+</configuration>]]></pre>
           </p>
         </subsection>
       </section>



Mime
View raw message