logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1519489 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
Date Mon, 02 Sep 2013 18:18:10 GMT
Author: rgoers
Date: Mon Sep  2 18:18:10 2013
New Revision: 1519489

URL: http://svn.apache.org/r1519489
Log:
Catch exceptions when initializing OnStartupTriggeringPolicy

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java?rev=1519489&r1=1519488&r2=1519489&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
Mon Sep  2 18:18:10 2013
@@ -18,9 +18,11 @@ package org.apache.logging.log4j.core.ap
 
 import java.lang.management.ManagementFactory;
 
+import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.status.StatusLogger;
 
 /**
  * Trigger a rollover on every restart. The target file's timestamp is compared with the
JVM start time
@@ -30,12 +32,22 @@ import org.apache.logging.log4j.core.con
 
 @Plugin(name = "OnStartupTriggeringPolicy", category = "Core", printObject = true)
 public class OnStartupTriggeringPolicy implements TriggeringPolicy {
-    private static final long JVM_START_TIME = ManagementFactory.getRuntimeMXBean().getStartTime();
+    private static long JVM_START_TIME = ManagementFactory.getRuntimeMXBean().getStartTime();
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
 
     private boolean evaluated = false;
 
     private RollingFileManager manager;
 
+    /* static {
+        try {
+            JVM_START_TIME = ManagementFactory.getRuntimeMXBean().getStartTime();
+        } catch (Exception ex) {
+            LOGGER.error("Unable to calculate JVM start time - {}", ex.getMessage());
+        }
+    } */
+
     /**
      * Provide the RollingFileManager to the policy.
      * @param manager The RollingFileManager.
@@ -43,6 +55,9 @@ public class OnStartupTriggeringPolicy i
     @Override
     public void initialize(final RollingFileManager manager) {
         this.manager = manager;
+        if (JVM_START_TIME == 0) {
+            evaluated = true;
+        }
     }
 
     /**



Mime
View raw message