[logback-dev] svn commit: r1067 - in logback/trunk: logback-examples/src/main/java/chapter6 logback-site/src/site/xdocTemplates/manual

noreply.seb at qos.ch noreply.seb at qos.ch
Wed Dec 6 14:51:07 CET 2006


Author: seb
Date: Wed Dec  6 14:51:06 2006
New Revision: 1067

Added:
   logback/trunk/logback-examples/src/main/java/chapter6/accessEventEvaluator2.xml
Modified:
   logback/trunk/logback-site/src/site/xdocTemplates/manual/filters.xml

Log:
added another examples of filter usage in lb access

Added: logback/trunk/logback-examples/src/main/java/chapter6/accessEventEvaluator2.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-examples/src/main/java/chapter6/accessEventEvaluator2.xml	Wed Dec  6 14:51:06 2006
@@ -0,0 +1,27 @@
+<configuration>
+
+	<appender name="STDOUT"
+		class="ch.qos.logback.core.ConsoleAppender">
+		<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+			<evaluator name="Eval404">
+				<expression>event.getStatusCode() == 404</expression>
+			</evaluator>
+			<OnMismatch>NEUTRAL</OnMismatch>
+			<OnMatch>ACCEPT</OnMatch>
+		</filter>
+		<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+			<evaluator name="EvalCSS">
+				<expression>event.getRequestURI().contains("css")</expression>
+			</evaluator>
+			<OnMismatch>NEUTRAL</OnMismatch>
+			<OnMatch>DENY</OnMatch>
+		</filter>
+		<layout class="ch.qos.logback.access.PatternLayout">
+			<pattern>
+				%h %l %u %t %r %s %b
+			</pattern>
+		</layout>
+	</appender>
+
+	<appender-ref ref="STDOUT" />
+</configuration>
\ No newline at end of file

Modified: logback/trunk/logback-site/src/site/xdocTemplates/manual/filters.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/manual/filters.xml	(original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/manual/filters.xml	Wed Dec  6 14:51:06 2006
@@ -389,26 +389,59 @@
 <em>Example 6.3: Access Evaluator (logback-examples/src/main/java/chapter6/accessEventEvaluator.xml)</em>
 <div class="source"><pre>&lt;configuration>
 
-	&lt;appender name="STDOUT"
-		class="ch.qos.logback.core.ConsoleAppender">
-		<b>&lt;filter class="ch.qos.logback.core.filter.EvaluatorFilter">
-			&lt;evaluator name="myEval">
-				&lt;expression>event.getStatusCode() == 404&lt;/expression>
-			&lt;/evaluator>
-			&lt;OnMismatch>NEUTRAL&lt;/OnMismatch>
-			&lt;OnMatch>ACCEPT&lt;/OnMatch>
-		&lt;/filter></b>
-		&lt;layout class="ch.qos.logback.access.PatternLayout">
-			&lt;pattern>
-				%h %l %u %t %r %s %b
-			&lt;/pattern>
-		&lt;/layout>
-	&lt;/appender>
+  &lt;appender name="STDOUT"
+    class="ch.qos.logback.core.ConsoleAppender">
+    <b>&lt;filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+      &lt;evaluator name="myEval">
+        &lt;expression>event.getStatusCode() == 404&lt;/expression>
+      &lt;/evaluator>
+      &lt;OnMismatch>NEUTRAL&lt;/OnMismatch>
+      &lt;OnMatch>ACCEPT&lt;/OnMatch>
+    &lt;/filter></b>
+    &lt;layout class="ch.qos.logback.access.PatternLayout">
+      &lt;pattern>
+        %h %l %u %t %r %s %b
+      &lt;/pattern>
+    &lt;/layout>
+  &lt;/appender>
 
-	&lt;appender-ref ref="STDOUT" />
+  &lt;appender-ref ref="STDOUT" />
 &lt;/configuration></pre></div>
 
+		<p>
+			We might imagine a slightly more complex use of filters to ensure the display of 404 errors, but
+			to prevent polluting the output with endless accesses to CSS files. Here is what such a configuration
+			would look like:
+		</p>	
 
+<em>Example 6.4: Access Evaluator (logback-examples/src/main/java/chapter6/accessEventEvaluator2.xml)</em>
+<div class="source"><pre>&lt;configuration>
+
+  &lt;appender name="STDOUT"
+    class="ch.qos.logback.core.ConsoleAppender">
+    <b>&lt;filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+      &lt;evaluator name="Eval404">
+        &lt;expression>event.getStatusCode() == 404&lt;/expression>
+      &lt;/evaluator>
+      &lt;OnMismatch>NEUTRAL&lt;/OnMismatch>
+      &lt;OnMatch>ACCEPT&lt;/OnMatch>
+    &lt;/filter>
+    &lt;filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+      &lt;evaluator name="EvalCSS">
+        &lt;expression>event.getRequestURI().contains("css")&lt;/expression>
+      &lt;/evaluator>
+      &lt;OnMismatch>NEUTRAL&lt;/OnMismatch>
+      &lt;OnMatch>DENY&lt;/OnMatch>
+    &lt;/filter></b>
+    &lt;layout class="ch.qos.logback.access.PatternLayout">
+      &lt;pattern>
+        %h %l %u %t %r %s %b
+      &lt;/pattern>
+    &lt;/layout>
+  &lt;/appender>
 
+  &lt;appender-ref ref="STDOUT" />
+&lt;/configuration></pre></div>	
+		
   </body>
 </document>
\ No newline at end of file



More information about the logback-dev mailing list