0 Replies Latest reply on Dec 19, 2011 12:02 PM by suikast42

    Log4j and JBoss LogManager

    suikast42

      Hi Guys,

       

      I have an EJB 2.1 application which running in JBOSS 5.1.0.GA with a remote java (swing) client.

       

      I try to migrate the application to EJB 3.1 with CDI. The switch to 3.1 is not so painful. Delete home interfaces delte ejb-jar xml etc.

       

      The lookup on EJBs with the new lookup machansim works fine too.

       

      Remote lookup to JMS Topics doesn't allready. Bu that is a another matter.

       

      I have currently a customized Repository selector. This selector do the application specfic logging configured by a log4j.xml file. When I get a Logger from my Selector the output comes to the console and not goes to my logfiles.

       

      I cast an eye at the sourcecode of the  org.jboss.logmanager.log4j.BridgeRepositorySelector. This selector sets itself as a selecotr by calling

       

      LogManager.setRepositorySelector(this, guard);

       

      And the logmanager throws an IllegalArgumentexception if I try to set my selector after the BridgeRepositorySelector do it. The related part of Logmanager is shown below.

       

      if((LogManager.guard != null) && (LogManager.guard != guard)) {

      throw new IllegalArgumentException(...)

      }

       

      So an aftercare setting of a selector is not possible.

       

      The BridgeR.epositorySelector gives a BridgeRepository object which create a BirdeLogger which shown below.

      public final class BridgeLogger extends org.apache.log4j.Logger {

      ...

      }

      The full code

      http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.logmanager/jboss-logmanager-log4j/1.0.0.CR3/org/jboss/logmanager/log4j/BridgeLogger.java#BridgeLogger.setAdditivity%28boolean%29

       

      The problem that I see is that this logger kill all the facilities of the Log4J logger. Beuase adding an appender and select the additivity is not posstible for this Logger. And that is the reason why my file appenders are dump.

       

      So I see two possibilies for solve my issue:

       

      1. Pack log4j.xml and log4j.jar in my EAR: The problem with this approch is the isolated class loading. Beause of Hornetq must I shut this off  http://community.jboss.org/message/576366). So I have a global classloader and JBoss has allready a log4j.jar in the libs.
      2. The second approach of my is to pack jboss-logging.xml in the META_INF of my EAR. But the appenders of the JBoss logging don't fullfil my claims. I need for example a periodic-file-appender which can controll the size and the number of files, too. Backup only one week for example. And I need a addivity behavior like log4j. I will have a silent logging. No console only file.

              In Log4j I wrote an custom appender and set the addivity flag to false and erverybody was lucky. So if I follow this approch I must have                 possiblity to write custom appenders.

       

      At last but not least. Can't you guys don't make a rollback to log4j, It was soooo easy.

       

      Thanks in advance.