logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1501421 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AbstractAppender.java
Date Tue, 09 Jul 2013 18:20:04 GMT
Author: ggregory
Date: Tue Jul  9 18:20:04 2013
New Revision: 1501421

URL: http://svn.apache.org/r1501421
Log:
Add parseInt method to abstract appender that logs to its own logger.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AbstractAppender.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AbstractAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AbstractAppender.java?rev=1501421&r1=1501420&r2=1501421&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AbstractAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/AbstractAppender.java
Tue Jul  9 18:20:04 2013
@@ -25,6 +25,7 @@ import org.apache.logging.log4j.core.Fil
 import org.apache.logging.log4j.core.Layout;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.filter.AbstractFilterable;
+import org.apache.logging.log4j.core.helpers.Integers;
 import org.apache.logging.log4j.status.StatusLogger;
 
 /**
@@ -53,6 +54,15 @@ public abstract class AbstractAppender<T
      */
     private boolean started = false;
 
+    public static int parseInt(String s, int defaultValue) {
+        try {
+            return Integers.parseInt(s, defaultValue);
+        } catch (NumberFormatException e) {
+            LOGGER.error("Could not parse \"{}\" as an integer,  using default value {}:
{}", s, defaultValue, e);
+            return defaultValue;
+        }
+    }
+
     /**
      * Constructor that defaults to suppressing exceptions.
      * @param name The Appender name.



Mime
View raw message