Hmm, as far as I can see (also written in FortressBean.initializeCommonsLogging() javadocs), latest commons-logging release (1.0.4) contains AvalonLogger (http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/impl/AvalonLogger.html).

also http://jakarta.apache.org/commons/logging/RELEASE-NOTES.txt contains a reference:

[AvalonLogger]     Added AvalonLogger, which wraps the logger used by the
                  Avalon framework.  As with other implementations, this
                  is compiled only if the appropriate dependencies are
                  satisfied.


and http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.4.jar
seems to contain it...


Should I revert the change? Or have I misunderstood the issue? :-)

[EMAIL PROTECTED] wrote:

Author: bloritsch
Date: Thu Jun 24 14:28:42 2004
New Revision: 22089

Added:
  
excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/AvalonLogger.java
Modified:
  
excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java
Log:
add AvalonLogger because none of the commons logging jars contains it

Added: 
excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/AvalonLogger.java
==============================================================================
--- (empty file)
+++ 
excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/AvalonLogger.java
   Thu Jun 24 14:28:42 2004
@@ -0,0 +1,115 @@
+package org.apache.avalon.fortress.tools;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.commons.logging.Log;
+
+/**
+ * Created by IntelliJ IDEA. User: bloritsch Date: Jun 24, 2004 Time:
+ * 5:07:47 PM To change this template use File | Settings | File
+ * Templates.
+ */
+public class AvalonLogger implements Log
+{
+    private static Logger m_default;
+    private Logger m_log;
+
+    public static void setDefaultLogger(Logger logger)
+    {
+        m_default = logger;
+    }
+
+    public AvalonLogger(String category)
+    {
+        m_log = m_default.getChildLogger( category );
+    }
+
+    public boolean isDebugEnabled()
+    {
+        return m_log.isDebugEnabled();
+    }
+
+    public boolean isErrorEnabled()
+    {
+        return m_log.isErrorEnabled();
+    }
+
+    public boolean isFatalEnabled()
+    {
+        return m_log.isFatalErrorEnabled();
+    }
+
+    public boolean isInfoEnabled()
+    {
+        return m_log.isInfoEnabled();
+    }
+
+    public boolean isTraceEnabled()
+    {
+        return m_log.isDebugEnabled();
+    }
+
+    public boolean isWarnEnabled()
+    {
+        return m_log.isWarnEnabled();
+    }
+
+    public void trace( Object o )
+    {
+        m_log.debug( o.toString() );
+    }
+
+    public void trace( Object o, Throwable throwable )
+    {
+        m_log.debug( o.toString(), throwable );
+    }
+
+    public void debug( Object o )
+    {
+        m_log.debug( o.toString() );
+    }
+
+    public void debug( Object o, Throwable throwable )
+    {
+        m_log.debug( o.toString(), throwable);
+    }
+
+    public void info( Object o )
+    {
+        m_log.info( o.toString() );
+    }
+
+    public void info( Object o, Throwable throwable )
+    {
+        m_log.info( o.toString(), throwable );
+    }
+
+    public void warn( Object o )
+    {
+        m_log.warn( o.toString() );
+    }
+
+    public void warn( Object o, Throwable throwable )
+    {
+        m_log.warn( o.toString(), throwable );
+    }
+
+    public void error( Object o )
+    {
+        m_log.error( o.toString() );
+    }
+
+    public void error( Object o, Throwable throwable )
+    {
+        m_log.error( o.toString(), throwable );
+    }
+
+    public void fatal( Object o )
+    {
+        m_log.fatalError( o.toString() );
+    }
+
+    public void fatal( Object o, Throwable throwable )
+    {
+        m_log.fatalError( o.toString(), throwable );
+    }
+}

Modified: excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java
==============================================================================
--- excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java (original)
+++ excalibur/trunk/fortress/bean/src/java/org/apache/avalon/fortress/tools/FortressBean.java Thu Jun 24 14:28:42 2004
@@ -1,16 +1,16 @@
-/* +/*
* Copyright 2003-2004 The Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at - * + * You may obtain a copy of the License at
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- * + *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
- * + *
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@@ -42,7 +42,6 @@
public class FortressBean implements Initializable, LogEnabled, Serviceable, Disposable {


    private static final String COMMONS_LOG_PROPERTY = 
"org.apache.commons.logging.Log";
-    private static final String COMMONS_AVALON_LOGGER = 
"org.apache.commons.logging.impl.AvalonLogger";

private final FortressConfig config = new FortressConfig();
private Logger logger = null;
@@ -89,7 +88,7 @@
// Get the root container initialized
this.cm = new DefaultContainerManager(config.getContext());
ContainerUtil.initialize(cm);
- initializeCommonsLogging(cl);
+ initializeCommonsLogging();
this.container = (DefaultContainer) cm.getContainer();
this.sm = container.getServiceManager();
}
@@ -99,22 +98,12 @@
* Use reflection to set up commons logging. If commons logging is available, it will be set up;
* if it is not available, this section is ignored. This needs version 1.0.4 (or later) of commons
* logging, earlier versions do not have avalon support.
- * - * @param cl class loader to look for commons logging classes
*/
- private void initializeCommonsLogging(ClassLoader cl) {
+ private void initializeCommonsLogging() {
try {
- //if commons logging is available, set the static logger for commons logging
- Class commonsLoggerClass;
- if (cl != null) {
- commonsLoggerClass = cl.loadClass(COMMONS_AVALON_LOGGER);
- } else {
- commonsLoggerClass = Class.forName(COMMONS_AVALON_LOGGER);
- }
- Method setDefaultLoggerMethod = commonsLoggerClass.getMethod("setDefaultLogger", new Class[] {Logger.class});
- setDefaultLoggerMethod.invoke(null, new Object[] {cm.getLogger()});
- //set the system property to use avalon logger
- System.setProperty(COMMONS_LOG_PROPERTY, COMMONS_AVALON_LOGGER);
+ AvalonLogger.setDefaultLogger( cm.getLogger() );
+
+ System.setProperty(COMMONS_LOG_PROPERTY, AvalonLogger.class.getName());
} catch (Exception e) {
if (getLogger().isDebugEnabled()) getLogger().debug("error while initializing commons logging: " + e.getClass().getName() + ", " + e.getMessage());
}
@@ -127,7 +116,7 @@
public static final String PROPERTY_CONTAINER_CLASS = "container.class";
public static final String PROPERTY_CONTAINER_CONFIGURATION = "container.configuration";
public static final String PROPERTY_CONTEXT_DIRECTORY = "context.directory";
- public static final String PROPERTY_INSTRUMENT_MANAGER_CONFIGURATION = + public static final String PROPERTY_INSTRUMENT_MANAGER_CONFIGURATION =
"instrument.manager.configuration";
public static final String PROPERTY_INVOKE_METHOD = "invoke.method";
public static final String PROPERTY_LOGGER_MANAGER_CONFIGURATION = "logger.manager.configuration";
@@ -213,9 +202,9 @@
}


/**
- * The container implementation has to be a subclass of + * The container implementation has to be a subclass of
* <code>org.apache.avalon.fortress.impl.DefaultContainer</code>.
- * + *
* @param containerClass fully qualified class name of the container implementation class.
*/
public void setContainerClass(String containerClass) throws Exception {


---------------------------------------------------------------------
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] Apache Excalibur Project -- URL: http://excalibur.apache.org/



Reply via email to