avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager MX4JLoggerAdapter.java MX4JSystemManager.java
Date Fri, 16 Aug 2002 05:55:44 GMT
hammant     2002/08/15 22:55:44

  Modified:    src/java/org/apache/avalon/phoenix/components/manager
                        MX4JSystemManager.java
  Added:       src/java/org/apache/avalon/phoenix/components/manager
                        MX4JLoggerAdapter.java
  Log:
  Patch logger for MX4J
  
  Revision  Changes    Path
  1.18      +5 -0      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MX4JSystemManager.java
  
  Index: MX4JSystemManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MX4JSystemManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MX4JSystemManager.java	6 Aug 2002 11:57:40 -0000	1.17
  +++ MX4JSystemManager.java	16 Aug 2002 05:55:44 -0000	1.18
  @@ -54,6 +54,8 @@
           m_port = configuration.getChild( "manager-adaptor-port" ).
               getValueAsInteger( DEFAULT_HTTPADAPTER_PORT );
   
  +        getLogger().debug("MX4J HTTP listener port: " + m_port);
  +
           m_rmi = configuration.getChild( "enable-rmi-adaptor" ).getValueAsBoolean( false
);
   
           m_namingFactory =
  @@ -78,6 +80,7 @@
           mBeanServer.createMBean( "mx4j.adaptor.http.HttpAdaptor", adaptorName, null );
           mBeanServer.setAttribute( adaptorName, new Attribute( "Port", new Integer( m_port
) ) );
   
  +
           /**
            // add user names
            m_mBeanServer.invoke(adaptorName,
  @@ -138,6 +141,8 @@
       protected MBeanServer createMBeanServer()
           throws Exception
       {
  +        MX4JLoggerAdapter.setLogger(getLogger());
  +        mx4j.log.Log.redirectTo(new MX4JLoggerAdapter());
           return MBeanServerFactory.createMBeanServer( "Phoenix" );
       }
   }
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MX4JLoggerAdapter.java
  
  Index: MX4JLoggerAdapter.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.phoenix.components.manager;
  
  import mx4j.log.Logger;
  
  /**
   * A class to pipe MX4J's own logger to the one Phoenix wants to use.
   */
  public class MX4JLoggerAdapter extends Logger
  {
      private static org.apache.avalon.framework.logger.Logger avalonLogger;
  
      /**
       * This is really bad.  A static way of introducing a logger to a tool.
       * @param logger the Avalon logger.
       */
      public static void setLogger(org.apache.avalon.framework.logger.Logger logger)
      {
          avalonLogger = logger;
      }
  
      /**
       * This overides the method in the super class to actually deliver Avalon
       * Logging to MX4J
       *
       * @param level the debug/warn/error level.
       * @param message the message to log.
       * @param throwable a message that may be sent.
       */
      protected void log(int level, Object message, Throwable throwable)
      {
          switch (level)
          {
              case mx4j.log.Logger.DEBUG:
                  avalonLogger.debug(message.toString(), throwable);
                  break;
              case mx4j.log.Logger.ERROR:
                  avalonLogger.error(message.toString(), throwable);
                  break;
              case mx4j.log.Logger.FATAL:
                  avalonLogger.fatalError(message.toString(), throwable);
                  break;
              case mx4j.log.Logger.INFO:
                  avalonLogger.info(message.toString(), throwable);
                  break;
              case mx4j.log.Logger.TRACE:
                  avalonLogger.debug(message.toString(), throwable);
                  break;
              case mx4j.log.Logger.WARN:
                  avalonLogger.warn(message.toString(), throwable);
                  break;
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message