geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1062609 - /geronimo/server/trunk/framework/modules/geronimo-pax-logging/src/main/java/org/apache/geronimo/logging/impl/LoggingServiceActivator.java
Date Mon, 24 Jan 2011 02:32:11 GMT
Author: gawor
Date: Mon Jan 24 02:32:10 2011
New Revision: 1062609

URL: http://svn.apache.org/viewvc?rev=1062609&view=rev
Log:
GERONIMO-5780: JUL output is lost after application resets logging

Modified:
    geronimo/server/trunk/framework/modules/geronimo-pax-logging/src/main/java/org/apache/geronimo/logging/impl/LoggingServiceActivator.java

Modified: geronimo/server/trunk/framework/modules/geronimo-pax-logging/src/main/java/org/apache/geronimo/logging/impl/LoggingServiceActivator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-pax-logging/src/main/java/org/apache/geronimo/logging/impl/LoggingServiceActivator.java?rev=1062609&r1=1062608&r2=1062609&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-pax-logging/src/main/java/org/apache/geronimo/logging/impl/LoggingServiceActivator.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-pax-logging/src/main/java/org/apache/geronimo/logging/impl/LoggingServiceActivator.java
Mon Jan 24 02:32:10 2011
@@ -17,6 +17,15 @@
 
 package org.apache.geronimo.logging.impl;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
 import org.apache.geronimo.logging.SystemLog;
 import org.apache.geronimo.main.ServerInfo;
 import org.ops4j.pax.logging.service.internal.Activator;
@@ -50,6 +59,27 @@ public class LoggingServiceActivator imp
         }
         
         activator.start(context);
+        
+        if (!Boolean.valueOf(context.getProperty("org.ops4j.pax.logging.skipJUL"))) {
+            // ensure PAX's JdkHandler is re-installed after JUL reset 
+            
+            final LogManager manager = LogManager.getLogManager();
+            final Handler[] paxHandlers = manager.getLogger("").getHandlers();
+
+            manager.addPropertyChangeListener(new PropertyChangeListener() {
+                public void propertyChange(PropertyChangeEvent evt) {
+                    Logger rootLogger = manager.getLogger("");
+                    Handler[] handlers = rootLogger.getHandlers();
+                    List<Handler> handlerList = (handlers == null) ? Collections.<Handler>emptyList()
: Arrays.asList(handlers);                    
+                    for (Handler h : paxHandlers) {
+                        if (!handlerList.contains(h)) {
+                            rootLogger.addHandler(h);
+                        }
+                    }
+                    rootLogger.warning("java.util.logging has been reset by application or
component");
+                }
+            });
+        }
     }
 
     private <T> T getService(BundleContext context, Class<T> name) {



Mime
View raw message