readConfiguration() broken in juli

View: New views
2 Messages — Rating Filter:   Alert me  

readConfiguration() broken in juli

by roger.keays :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

I first ran into bug 39627 [1] when trying to get my logging working
properly and got to have a pretty thorough read of the JULI code. I
noticed that the readConfiguration(stream) method doesn't reset the
configuration properly. It just calls a super.reset(), but the
superclass doesn't know about the special per-classloader loggers.

Should I file a bug? I have a simple patch which just creates a new
ClassLoaderLogInfo for every readConfiguration() call and lets the
garbage collector to delete the old one.

I'm a bit confused about the way logging configuration is inherited by
classloaders though. My patch doesn't reset any configuration in parent
classloaders and I'm not sure what consequences this will have.

Roger

[1] http://issues.apache.org/bugzilla/show_bug.cgi?id=39627
--
----------------------------------------
Ninth Avenue Software
p: +61 7 3137 1351 (UTC +10)
f: +61 7 3102 9141
w: http://www.ninthavenue.com.au
e: info@...
----------------------------------------

Index: org/apache/juli/ClassLoaderLogManager.java
===================================================================
--- org/apache/juli/ClassLoaderLogManager.java (revision 412714)
+++ org/apache/juli/ClassLoaderLogManager.java (working copy)
@@ -241,7 +241,6 @@
         throws IOException, SecurityException {
         
         checkAccess();
-        reset();
 
         readConfiguration(is, Thread.currentThread().getContextClassLoader());
     
@@ -318,29 +317,18 @@
                 }
             }
         }
-        
-        Logger localRootLogger = new RootLogger();
-        if (is == null) {
-            // Retrieve the root logger of the parent classloader instead
-            ClassLoader current = classLoader.getParent();
-            ClassLoaderLogInfo info = null;
-            while (current != null && info == null) {
-                info = getClassLoaderInfo(current);
-                current = current.getParent();
-            }
-            if (info != null) {
-                localRootLogger.setParent(info.rootNode.logger);
-            }
-        }
-        ClassLoaderLogInfo info =
-            new ClassLoaderLogInfo(new LogNode(null, localRootLogger));
-        info.loggers.put("", localRootLogger);
-        classLoaderLoggers.put(classLoader, info);
-        
+      
         if (is != null) {
             readConfiguration(is, classLoader);
+        } else {
+
+            /* empty logging tree */  
+            Logger localRootLogger = new RootLogger();
+            ClassLoaderLogInfo info =
+                new ClassLoaderLogInfo(new LogNode(null, localRootLogger));
+            classLoaderLoggers.put(classLoader, info);
         }
-        
+
     }
     
     
@@ -354,9 +342,11 @@
     protected void readConfiguration(InputStream is, ClassLoader classLoader)
         throws IOException {
         
+        Logger localRootLogger = new RootLogger();
         ClassLoaderLogInfo info =
-            (ClassLoaderLogInfo) classLoaderLoggers.get(classLoader);
-        
+            new ClassLoaderLogInfo(new LogNode(null, localRootLogger));
+        classLoaderLoggers.put(classLoader, info);
+        
         try {
             info.props.load(is);
         } catch (IOException e) {
@@ -372,7 +362,6 @@
         // Create handlers for the root logger of this classloader
         String rootHandlers = info.props.getProperty(".handlers");
         String handlers = info.props.getProperty("handlers");
-        Logger localRootLogger = info.rootNode.logger;
         if (handlers != null) {
             StringTokenizer tok = new StringTokenizer(handlers, ",");
             while (tok.hasMoreTokens()) {
@@ -423,6 +412,7 @@
             }
             
         }
+        addLogger(localRootLogger);
         
     }
     
@@ -487,6 +477,9 @@
 
         LogNode findNode(String name) {
             LogNode currentNode = this;
+            if (logger.getName().equals(name)) {
+                return this;
+            }
             while (name != null) {
                 final int dotIndex = name.indexOf('.');
                 final String nextName;

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

Re: readConfiguration() broken in juli

by markt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Roger Keays wrote:
> Should I file a bug? I have a simple patch which just creates a new
> ClassLoaderLogInfo for every readConfiguration() call and lets the
> garbage collector to delete the old one.

Patches are best attached to bug reports. They tend to get lost in the
noise on the lists if not acted on immediately.

Since this is a known issue, attach the patch to the bug report.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...