You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2007/03/19 03:56:24 UTC

DO NOT REPLY [Bug 33708] - XML Configuration of loggerFactory does not work

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33708>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33708


pfurbacher@mac.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carnold@apache.org
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Additional Comments From pfurbacher@mac.com  2007-03-18 19:56 -------
Based on my own attempts to use <categoryFactory> element in log4j-1.2.13, I
find that this bug in DOMConfigurator is *not* fixed.  The same symptoms prevail
as shown by the original poster: i.e., a ClassCastException.  (I could find no
test case for either categoryFactory or loggerFactory configuration in
log4j.xml, so I don't know how anyone could claim it is fixed.)

It would be nice if it could get fixed for log4j-1.2.15.  

The following diff shows how to fix this problem.

--- src/java/org/apache/log4j/xml/DOMConfigurator.java  2007-02-23 12:48:53.408
-0500     511036
+++ src/java/org/apache/log4j/xml/DOMConfigurator.java  2007-03-18 22:25:07.597
-0500
@@ -109,6 +109,9 @@
   Properties props;
   LoggerRepository repository;
 
+
+  protected LoggerFactory catFactory = null;
+
   /**
      No argument constructor.
   */
@@ -258,7 +261,10 @@
 	    eh.setBackupAppender(findAppenderByReference(currentElement));
 	  } else if(tagName.equals(LOGGER_REF)) {
 	    String loggerName = currentElement.getAttribute(REF_ATTR);	    
-	    Logger logger = repository.getLogger(loggerName);
+      Logger logger =
+          (catFactory == null)
+          ? repository.getLogger(loggerName)
+          : repository.getLogger(loggerName, catFactory);
 	    eh.setLogger(logger);
 	  } else if(tagName.equals(ROOT_REF)) {
 	    Logger root = repository.getRootLogger();
@@ -317,7 +323,9 @@
 
     if(EMPTY_STR.equals(className)) {
       LogLog.debug("Retreiving an instance of org.apache.log4j.Logger.");
-      cat = repository.getLogger(catName);
+      cat = (catFactory == null )
+          ? repository.getLogger(catName)
+          : repository.getLogger(catName, catFactory);
     }
     else {
       LogLog.debug("Desired logger sub-class: ["+className+']');
@@ -361,8 +369,8 @@
     }
     else {
       LogLog.debug("Desired category factory: ["+className+']');
-      Object catFactory = OptionConverter.instantiateByClassName(className, 
-                                                                
LoggerFactory.class, 
+      catFactory = (LoggerFactory)OptionConverter.instantiateByClassName(className,
+                                                                
LoggerFactory.class,
                                                                  null);
       PropertySetter propSetter = new PropertySetter(catFactory);
 


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org