[logback-dev] svn commit: r2281 - in logback-demo/trunk/src/main: java/ch/qos/logback/demo/prime resources resources/parts

noreply.ceki at qos.ch noreply.ceki at qos.ch
Thu Jun 11 16:43:03 CEST 2009


Author: ceki
Date: Thu Jun 11 16:43:03 2009
New Revision: 2281

Modified:
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeAction.java
   logback-demo/trunk/src/main/resources/logback.xml
   logback-demo/trunk/src/main/resources/parts/sifting.xml

Log:
- 99 is a sentinel value in PrimeAction.java (causing an exception to be thrown)
- other improvements

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeAction.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeAction.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeAction.java	Thu Jun 11 16:43:03 2009
@@ -23,6 +23,9 @@
       PrimeForm form = (PrimeForm) actionForm;
 
       Long number = form.getNumber();
+      if(number == 99) {
+    	  logger.info("99 is not a valid value", new Exception("99 is invalid"));
+      }
       NumberCruncher nc = new NumberCruncherImpl();
       Long start = System.currentTimeMillis();
       Long[] result = nc.factor(number);

Modified: logback-demo/trunk/src/main/resources/logback.xml
==============================================================================
--- logback-demo/trunk/src/main/resources/logback.xml	(original)
+++ logback-demo/trunk/src/main/resources/logback.xml	Thu Jun 11 16:43:03 2009
@@ -28,54 +28,75 @@
     </layout>
   </appender>
 
-  <!-- Basic Cyclic buffer    
+  <!-- Basic Cyclic buffer 
     <appender name="CYCLIC"
     class="ch.qos.logback.core.read.CyclicBufferAppender">
     <MaxSize>512</MaxSize>
     </appender>
   -->
 
-  <!-- Cyclic buffer with Evaluator 
+  <!-- Cyclic buffer with Evaluator --> 
   <appender name="CYCLIC"
     class="ch.qos.logback.core.read.CyclicBufferAppender">
     <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
       <evaluator name="loggingTaskEval">
         <expression>
-          logger.getName().contains("LoggingTask") &amp;&amp;
+          logger.contains("LoggingTask") &amp;&amp;
           message.contains("Howdydy-diddly-ho") &amp;&amp; (timeStamp -
-          event.getStartTime()) >= 20000
+          loggerContext.getBirthTime()) >= 20000
         </expression>
       </evaluator>
       <OnMatch>DENY</OnMatch>
     </filter>
     <MaxSize>512</MaxSize>
   </appender>
-  -->
+  
   
 
   <!-- TurboFilter: by MDC value 
-    <turboFilter class="ch.qos.logback.classic.turbo.MDCFilter">
-    <MDCKey>username</MDCKey>
+  <turboFilter class="ch.qos.logback.classic.turbo.MDCFilter">
+    <MDCKey>userid</MDCKey>
     <Value>sebastien</Value>
     <OnMatch>ACCEPT</OnMatch>
-    </turboFilter>
+  </turboFilter>
   -->
 
   <!-- TurboFilter: by Marker   
-    <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
+  <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
     <Name>HOWDY_FILTER</Name>
     <Marker>HOWDY</Marker>
     <OnMatch>DENY</OnMatch>
-    </turboFilter>
+  </turboFilter>
   -->
 
-  <!-- JMX Configurator -->
+  <!-- JMX Configurator  -->
   <jmxConfigurator />
 
+  <appender name="SIFT"
+            class="ch.qos.logback.classic.sift.SiftingAppender">
+    <discriminator>
+      <Key>userid</Key>
+      <DefaultValue>unknown</DefaultValue>
+    </discriminator>
+    <sift>
+      <appender name="FILE-${userid}"
+                class="ch.qos.logback.core.FileAppender">
+        <File>${userid}.log</File>
+        <Append>false</Append>
+        <layout>
+          <Pattern>
+            %d [%thread] %-55(%-5level %10mdc %logger{35}) - %msg%n
+          </Pattern>
+        </layout>
+      </appender>
+    </sift>
+  </appender>
+
 
   <root level="${lb_level:-ERROR}">
     <appender-ref ref="STDOUT" />
-    <appender-ref ref="FILE" />
+    <appender-ref ref="SIFT" />
+    <appender-ref ref="CYCLIC" />
   </root>
 
 </configuration>

Modified: logback-demo/trunk/src/main/resources/parts/sifting.xml
==============================================================================
--- logback-demo/trunk/src/main/resources/parts/sifting.xml	(original)
+++ logback-demo/trunk/src/main/resources/parts/sifting.xml	Thu Jun 11 16:43:03 2009
@@ -11,7 +11,7 @@
         <Append>false</Append>
         <layout>
           <Pattern>
-            %d [%thread] %55(%5level %10mdc %logger{35}) - %msg%n
+            %d [%thread] %-55(%-5level %10mdc %logger{35}) - %msg%n
           </Pattern>
         </layout>
       </appender>


More information about the logback-dev mailing list