geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender ConsoleAppenderService.java
Date Wed, 25 Feb 2004 07:53:20 GMT
dain        2004/02/24 23:53:20

  Modified:    modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender
                        ConsoleAppenderService.java
  Log:
  Changed console appender to wrap any console appender already registered
  witht the root log or it will create a new one
  
  Revision  Changes    Path
  1.2       +29 -2     incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/ConsoleAppenderService.java
  
  Index: ConsoleAppenderService.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/ConsoleAppenderService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConsoleAppenderService.java	12 Feb 2004 18:12:52 -0000	1.1
  +++ ConsoleAppenderService.java	25 Feb 2004 07:53:20 -0000	1.2
  @@ -56,10 +56,14 @@
   
   package org.apache.geronimo.system.logging.log4j.appender;
   
  +import java.util.Enumeration;
  +
   import org.apache.geronimo.gbean.GAttributeInfo;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.log4j.ConsoleAppender;
  +import org.apache.log4j.Logger;
  +import org.apache.log4j.Appender;
   
   /**
    * An extention of the default Log4j DailyRollingFileAppender
  @@ -69,7 +73,30 @@
    */
   public class ConsoleAppenderService extends AbstractAppenderService {
       public ConsoleAppenderService() {
  -        super(new ConsoleAppender());
  +        super(getConsoleAppender());
  +    }
  +
  +    private static ConsoleAppender getConsoleAppender() {
  +        Logger root = Logger.getRootLogger();
  +        for(Enumeration enum = root.getAllAppenders(); enum.hasMoreElements();) {
  +            Appender appender = (Appender)enum.nextElement();
  +            if (appender instanceof ConsoleAppender) {
  +                return (ConsoleAppender)appender;
  +            }
  +        }
  +        return new ConsoleAppender();
  +    }
  +
  +    public void doStart() {
  +        appender.activateOptions();
  +        Logger root = Logger.getRootLogger();
  +        root.addAppender(appender);
  +    }
  +
  +    public void doStop() {
  +    }
  +
  +    public void doFail() {
       }
   
       public String getTarget() {
  
  
  

Mime
View raw message