logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbrou...@apache.org
Subject svn commit: r1610904 - in /logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j: simple/SimpleLogger.java status/StatusLogger.java
Date Wed, 16 Jul 2014 02:29:13 GMT
Author: bbrouwer
Date: Wed Jul 16 02:29:12 2014
New Revision: 1610904

URL: http://svn.apache.org/r1610904
Log:
Revert to (mostly) previous version that still includes StatusConsoleListener

Modified:
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
    logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java?rev=1610904&r1=1610903&r2=1610904&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLogger.java
Wed Jul 16 02:29:12 2014
@@ -36,7 +36,7 @@ import org.apache.logging.log4j.util.Pro
 /**
  *  This is the default logger that is used when no suitable logging implementation is available.
  */
-public class SimpleLogger extends AbstractLogger implements Closeable {
+public class SimpleLogger extends AbstractLogger {
 
     private static final long serialVersionUID = 1L;
 
@@ -179,9 +179,4 @@ public class SimpleLogger extends Abstra
     public void setStream(final PrintStream stream) {
         this.stream = stream;
     }
-
-    @Override
-    public void close() throws IOException {
-        this.stream.close();
-    }
 }

Modified: logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java?rev=1610904&r1=1610903&r2=1610904&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-609/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
Wed Jul 16 02:29:12 2014
@@ -57,6 +57,8 @@ public final class StatusLogger extends 
     
     private static final int MAX_ENTRIES = PROPS.getIntegerProperty(MAX_STATUS_ENTRIES, 200);
 
+    private static final String DEFAULT_STATUS_LEVEL = PROPS.getStringProperty("log4j2.StatusLogger.level");
+
     private static final StatusLogger STATUS_LOGGER = new StatusLogger();
 
     private final SimpleLogger logger;
@@ -68,11 +70,8 @@ public final class StatusLogger extends 
     private final Lock msgLock = new ReentrantLock();
 
     private StatusLogger() {
-    	final Level consoleLevel = Level.toLevel(PROPS.getStringProperty("log4j2.StatusLogger.console.level"),
Level.ERROR);
-    	final PrintStream consoleDest ="out".equalsIgnoreCase(PROPS.getStringProperty("log4j2.StatusLogger.console.destination"))
? System.out : System.err; 
-    			
-		this.logger = new SimpleLogger("StatusLogger", consoleLevel, false,
-				true, false, false, Strings.EMPTY, null, PROPS, consoleDest);
+        this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, true, false, false,
Strings.EMPTY, null, PROPS,
+                System.err);
     }
 
     /**
@@ -186,7 +185,6 @@ public final class StatusLogger extends 
      */
     @Override
     public void logMessage(final String fqcn, final Level level, final Marker marker, final
Message msg, final Throwable t) {
-        logger.logMessage(fqcn, level, marker, msg, t);
         StackTraceElement element = null;
         if (fqcn != null) {
             element = getStackTraceElement(fqcn, Thread.currentThread().getStackTrace());
@@ -198,10 +196,14 @@ public final class StatusLogger extends 
         } finally {
             msgLock.unlock();
         }
-        for (final StatusListener listener : listeners) {
-            if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
-                listener.log(data);
+        if (listeners.size() > 0) {
+            for (final StatusListener listener : listeners) {
+                if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
+                    listener.log(data);
+                }
             }
+        } else {
+            logger.logMessage(fqcn, level, marker, msg, t);
         }
     }
 
@@ -251,8 +253,8 @@ public final class StatusLogger extends 
 
     @Override
     public boolean isEnabled(final Level level, final Marker marker) {
-        if (logger.isEnabled(level)) {
-        	return true;
+        if (listeners.isEmpty()) {
+        	return logger.isEnabled(level);
         }
     	for (StatusListener listener : listeners) {
     		if (level.isLessSpecificThan(listener.getStatusLevel())) {



Mime
View raw message