[logback-dev] svn commit: r2080 - in logback-demo/trunk/src: etc main/java/ch/qos/logback/demo main/java/ch/qos/logback/demo/prime main/java/ch/qos/logback/demo/reload main/java/ch/qos/logback/demo/statii main/java/ch/qos/logback/demo/util main/resources

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon Dec 15 22:41:47 CET 2008


Author: ceki
Date: Mon Dec 15 22:41:47 2008
New Revision: 2080

Modified:
   logback-demo/trunk/src/etc/logback-access.xml
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/LoggingTask.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/ViewLastLog.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/NumberCruncherImpl.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeForm.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/reload/ReloadConfigAction.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java
   logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java
   logback-demo/trunk/src/main/resources/logback.xml

Log:


Modified: logback-demo/trunk/src/etc/logback-access.xml
==============================================================================
--- logback-demo/trunk/src/etc/logback-access.xml	(original)
+++ logback-demo/trunk/src/etc/logback-access.xml	Mon Dec 15 22:41:47 2008
@@ -50,14 +50,16 @@
 	-->
 	
 	
-	<!-- Part JMX
+	<!-- Part JMX 
   <filter class="ch.qos.logback.access.filter.CountingFilter">
 		<name>countingFilter</name>
 	</filter>	
 	-->
-	
+
+  <!--  
   <appender-ref ref="STDOUT" />
-  
+  -->
+
   <!-- Lottery to Console 
 	<appender-ref ref="STDOUT_LOTTERY" />
 	-->

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/LoggingTask.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/LoggingTask.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/LoggingTask.java	Mon Dec 15 22:41:47 2008
@@ -8,17 +8,24 @@
 public class LoggingTask implements Runnable {
 
   static Marker HOWDY_MARKER = MarkerFactory.getMarker("HOWDY");
+  static Marker TOTO = MarkerFactory.getMarker("TOTO");
+
+  static {
+    TOTO.add(HOWDY_MARKER);
+  }
   Logger logger = LoggerFactory.getLogger(LoggingTask.class);
-  
+
   String msg;
+
   int i = 0;
-  
+
   LoggingTask(String msg) {
     this.msg = msg;
   }
+
   public void run() {
-    //logger.info(msg +" - " + (i++));
-    logger.info(HOWDY_MARKER, msg +" - " + (i++));
+    // logger.info(msg +" - " + (i++));
+    logger.info(HOWDY_MARKER, msg + " - " + (i++), new Exception("e"));
   }
 
 }

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/ViewLastLog.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/ViewLastLog.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/ViewLastLog.java	Mon Dec 15 22:41:47 2008
@@ -16,11 +16,11 @@
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.html.HTMLLayout;
 import ch.qos.logback.classic.html.UrlCssBuilder;
+import ch.qos.logback.classic.spi.LoggerContextListener;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.core.read.CyclicBufferAppender;
-import ch.qos.logback.classic.spi.ContextListener;
 
-public class ViewLastLog extends HttpServlet implements ContextListener {
+public class ViewLastLog extends HttpServlet implements LoggerContextListener {
 
   private static final long serialVersionUID = -3551928133801157219L;
   private boolean listening = false;
@@ -119,4 +119,11 @@
     layout.setTitle("Last Logging Events");
     layout.start();
   }
+
+  public boolean isResetResistant() {
+    return false;
+  }
+
+  public void onStop(LoggerContext arg0) {
+  }
 }

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/NumberCruncherImpl.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/NumberCruncherImpl.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/NumberCruncherImpl.java	Mon Dec 15 22:41:47 2008
@@ -33,8 +33,11 @@
     logger.info("Beginning to factor.");
 
     if (number <= 0) {
-      throw new IllegalArgumentException(number +
+    	IllegalArgumentException e = new IllegalArgumentException(number +
         " is not a positive integer.");
+      logger.error("Bad argument", e);
+      //throw e;
+      return new Long[] { 0L };
     } else if (number == 1) {
       return new Long[] { 1L };
     }
@@ -51,8 +54,8 @@
         logger.warn("Already tried " + MAX_COUNT_BEFORE_WARN + " factors.");
         count = 0;
       }
-      logger.debug("Trying "+i+" as a factor.");
-      //logger.debug("Trying {} as a factor.", i);
+      //logger.debug("Trying "+i+" as a factor.");
+      logger.debug("Trying {} as a factor.", i);
 
       if ((n % i) == 0) {
         logger.info("Found factor " + i);

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeForm.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeForm.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/prime/PrimeForm.java	Mon Dec 15 22:41:47 2008
@@ -26,7 +26,7 @@
       ActionMapping mapping, HttpServletRequest request ) {
       ActionErrors errors = new ActionErrors();
       
-      if( getNumber() == null || getNumber().longValue() < 1 ) {
+      if( getNumber() == null || ((getNumber().longValue()) != -1 &&  (getNumber().longValue() < 1))) {
         errors.add("number",new ActionMessage("errors.minNumber"));
       }
 

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/reload/ReloadConfigAction.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/reload/ReloadConfigAction.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/reload/ReloadConfigAction.java	Mon Dec 15 22:41:47 2008
@@ -64,7 +64,7 @@
         configurator.setContext(lc);
         logger.info("Shutting down active logging configuration.");
 
-        lc.shutdownAndReset();
+        lc.reset();
         configurator.doConfigure(url);
         lc.start();
         logger.info("Now using new configuration.");

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseContextAction.java	Mon Dec 15 22:41:47 2008
@@ -31,12 +31,12 @@
       ChooseContextForm form = (ChooseContextForm) actionForm;
 
       String contextName = form.getContextName();
-      LoggerContext context = StaticLoggerBinder.SINGLETON.getContextSelector().getLoggerContext(contextName);
+      LoggerContext context = StaticLoggerBinder.getSingleton().getContextSelector().getLoggerContext(contextName);
       EnhancedStatusPrinter.print(buf, context.getStatusManager());
       request.setAttribute(Constants.STATUS, buf.toString());
     }
     
-    List<String> contextNames = StaticLoggerBinder.SINGLETON.getContextSelector().getContextNames();
+    List<String> contextNames = StaticLoggerBinder.getSingleton().getContextSelector().getContextNames();
     request.setAttribute(Constants.CONTEXT_LIST, contextNames);
     
     return actionMapping.findForward("next");

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/statii/ChooseModuleAction.java	Mon Dec 15 22:41:47 2008
@@ -48,7 +48,7 @@
         request.setAttribute(Constants.STATUS, buf.toString());
 
       } else {
-        List<String> contextNames = StaticLoggerBinder.SINGLETON.getContextSelector().getContextNames();
+        List<String> contextNames = StaticLoggerBinder.getSingleton().getContextSelector().getContextNames();
         request.setAttribute(Constants.CONTEXT_LIST, contextNames);
       }
     }

Modified: logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java
==============================================================================
--- logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java	(original)
+++ logback-demo/trunk/src/main/java/ch/qos/logback/demo/util/EnhancedStatusPrinter.java	Mon Dec 15 22:41:47 2008
@@ -3,18 +3,17 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.text.SimpleDateFormat;
-
 import java.util.Iterator;
 import java.util.List;
 
-import ch.qos.logback.classic.pattern.ClassNameAbbreviator;
+import ch.qos.logback.classic.pattern.TargetLengthBasedClassNameAbbreviator;
 import ch.qos.logback.core.status.Status;
 import ch.qos.logback.core.status.StatusManager;
 
 public class EnhancedStatusPrinter {
   
   private static final int ABBR_LENGTH = 17;
-  private static ClassNameAbbreviator abbreviator = new ClassNameAbbreviator(ABBR_LENGTH);
+  private static TargetLengthBasedClassNameAbbreviator abbreviator = new TargetLengthBasedClassNameAbbreviator(ABBR_LENGTH);
   private static SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd'T'HH:mm:ss");
 
   public static String print(Status s) {
@@ -81,7 +80,6 @@
         Status child = ite.next();
         print(buf, indentation+"  ", child);
       }
-      
     }
   }
   

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	Mon Dec 15 22:41:47 2008
@@ -5,7 +5,7 @@
   <appender name="STDOUT"
 		class="ch.qos.logback.core.ConsoleAppender">
 		<layout class="ch.qos.logback.classic.PatternLayout">
-			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n</pattern>
+			<pattern>%marker %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n</pattern>
 		</layout>
 	</appender>
   
@@ -15,25 +15,26 @@
 		<rollingPolicy
 			class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
 			<FileNamePattern>
-				logFile.%d{yyyy-MM-dd_HH-mm}.log.zip
+				z:/logFile.%d{yyyy-MM-dd_HH-mm}.log.zip
 			</FileNamePattern>
+      <maxHistory>5</maxHistory>
 		</rollingPolicy>
 
 		<layout class="ch.qos.logback.classic.PatternLayout">
-			<Pattern>
-				%-26(%d{HH:mm:ss,SSS} [%thread]) %-5level %logger{32} - %msg%n
+			<Pattern>%marker %-26(%d{HH:mm:ss,SSS} [%thread]) %-5level %logger{32} - %msg%n
 			</Pattern>
 		</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">
@@ -47,37 +48,43 @@
 			<OnMatch>DENY</OnMatch>
 		</filter>
 		<MaxSize>512</MaxSize>
-	-->
-  
-	<!-- TurboFilter: by MDC value 
+  </appender>
+
+
+	<!-- TurboFilter: by MDC value    
   <turboFilter class="ch.qos.logback.classic.turbo.MDCFilter">
 		<MDCKey>username</MDCKey>
 		<Value>sebastien</Value>
 		<OnMatch>ACCEPT</OnMatch>
 	</turboFilter>  
-	-->
+ -->
 	
-	<!-- TurboFilter: by Marker 
+	<!-- TurboFilter: by Marker   -->
+  <!--   
   <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
     <Name>HOWDY_FILTER</Name>
 		<Marker>HOWDY</Marker>
 		<OnMatch>DENY</OnMatch>
 	</turboFilter>
-	-->
+-->
 	  
+  
 	<!-- JMX Configurator -->
+  <!--   -->
   <jmxConfigurator />
-	
+
+
 	<root>
 		<level value="DEBUG" />
     
 		<appender-ref ref="STDOUT" />		
     <appender-ref ref="FILE" />
-		
-		<!-- Part I: Basic Cyclic buffer
+
+    <!--		    
+		Part I: Basic Cyclic buffer        -->
    	<appender-ref ref="CYCLIC" />
-    -->
-     
+
+
 	</root>
 
 </configuration>


More information about the logback-dev mailing list