Hi,
 
Unfortunately, I am not using JBoss so I am not sure why that is happening to you.  
Here is the javadoc from LogManger.setRepositorySelector()
 
/**
     Sets <code>LoggerFactory</code> but only if the correct
     <em>guard</em> is passed as parameter.
     <p>Initally the guard is null.  If the guard is
     <code>null</code>, then invoking this method sets the logger
     factory and the guard. Following invocations will throw a [EMAIL PROTECTED]
     IllegalArgumentException}, unless the previously set
     <code>guard</code> is passed as the second parameter.
     <p>This allows a high-level component to set the [EMAIL PROTECTED]
     RepositorySelector} used by the <code>LogManager</code>.
     <p>For example, when tomcat starts it will be able to install its
     own repository selector. However, if and when Tomcat is embedded
     within JBoss, then JBoss will install its own repository selector
     and Tomcat will use the repository selector set by its container,
     JBoss.  */
 
It looks like the log4j developers know that JBoss is setting its own LoggerFactory.  
You should probably check the log4j mailing list and the JBoss mailing list to see if 
anyone has a work-around for that.  It could be that when you call 
setRepositorySelector the method is throwing the IllegalArgumentException since you 
don't have the right guard.  Since the exception would be thrown in the static block 
it could be that JBoss is choking on it and hanging since it is not expecting a 
RuntimeException at that point in program execution.
 
Good Luck,
Mark
 
-----Original Message----- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Fri 9/26/2003 9:53 PM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: RE: Need help on categoryFactory in XML config files [BUG 21707]



        Thanks Mark.
        
        It was really helpful.. but I'm still seeing problems when I use it in the
        context of the JBoss app server.
        
        At the time of JBoss server coming up.. it hangs as if its waiting for
        something.
        If I comment out the static LogManager.setRepositorySelector(....) block..
        it comes up nice and clean but without the loggerFactory initialization.
        
        Is it possible to find out what is it waiting for??
        
        I'm using following declaration in the XML file...
        
                 <categoryFactory class="com.**.*Factory"/>
        
        Thanks in advance
        
        
        -----Original Message-----
        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
        Sent: Friday, September 12, 2003 3:59 PM
        To: [EMAIL PROTECTED]
        Subject: RE: Need help on categoryFactory in XML config files [BUG
        21707]
        
        
        Hi,
        
        The bug that you are referring to has not been resolved.  You can try the
        work-around that I posted in
        http://marc.theaimsgroup.com/?l=log4j-user&m=106312777504479&w=2.  That
        worked for me and now the loggers returned by Logger.getLogger(class) are my
        Logger subclasses. 
        
        Here is the basic code I used:
        
        /**
         * @author Mark Priest
         *
         */
        public class MTPLog4jRepositorySelector
                extends Hierarchy implements RepositorySelector
        {
            protected MTPLog4jLoggerFactory _factory;
                /**
                 * @param root
                 */
                public MTPLog4jRepositorySelector(Logger root,
                MTPLog4jLoggerFactory factory)
                {
                        super(root);
                _factory = factory;
                }
        
            public Logger getLogger(String name) {
              return getLogger(name, _factory);
            }
        
                /**
                 * @see
        org.apache.log4j.spi.RepositorySelector#getLoggerRepository()
                 */
                public LoggerRepository getLoggerRepository()
                {
                        return this;
                }
        }
        
        /**
         *
         * @author Mark Priest
         *
         */
        public class MTPLog4jLoggerFactory implements LoggerFactory
        {
            protected static final MTPLog4jLoggerFactory _factory;
           
                /**
                 * @see
        org.apache.log4j.spi.LoggerFactory#makeNewLoggerInstance(java.lang.String)
                 */
                public Logger makeNewLoggerInstance(String name)
                {
                Logger logger = new MTPLogger(name);
                return logger;
                }
           
            static
            {
                _factory = new MTPLog4jLoggerFactory();
                // set the repository selector
                LogManager.setRepositorySelector(
                    new MTPLog4jRepositorySelector(LogManager.getRootLogger(),
                    _factory), _factory);
            }
        }
        
        -----Original Message-----
        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
        Sent: Friday, September 12, 2003 6:50 PM
        To: [EMAIL PROTECTED]
        Subject: FW: Need help on categoryFactory in XML config files [BUG
        21707]
        
        
        
        
        We are using log4j 1.2.8. in our project (J2EE on WLS server). We have
        sub-classed the Logger and LoggerFactory according to the examples. We
        are
        using
        an XML file for configuration.
        
        When we use <logger> or <category> (without the class attribute) and
        <categoryFactory> in our log4j.xml, the DOMConfigurator is creating
        Logger
        instances (instead of sub-classes created by our factory) during
        startup:
        
        ALSO we need to declare category for each class in a package ..We CANNOT
        specify at the package level either
        
        For e.g;
        
          <category name="com.x.y.z.Foo"    class="ch.postfinance.log.PFLogger">
            <level value="INFO"/>
          </category>
        
        IS THE BUG 21707 Resolved????? Bug 21707] New: - Problem with
        <categoryFactory> in log4j.xml for LoggerFactory sub-class
        
        Thanks in advance
        
        
        ---------------------------------------------------------------------
        To unsubscribe, e-mail: [EMAIL PROTECTED]
        For additional commands, e-mail: [EMAIL PROTECTED]
        
        ---------------------------------------------------------------------
        To unsubscribe, e-mail: [EMAIL PROTECTED]
        For additional commands, e-mail: [EMAIL PROTECTED]
        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to