cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r202547 - in /cocoon: blocks/portal/trunk/java/org/apache/cocoon/portlet/ trunk/src/java/org/apache/cocoon/bean/ trunk/src/java/org/apache/cocoon/core/ trunk/src/java/org/apache/cocoon/servlet/ trunk/src/test/org/apache/cocoon/test/core/
Date Thu, 30 Jun 2005 12:24:59 GMT
Author: cziegeler
Date: Thu Jun 30 05:24:57 2005
New Revision: 202547

URL: http://svn.apache.org/viewcvs?rev=202547&view=rev
Log:
Reduce dependency to LogKit

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java   (with props)
Removed:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletOutputLogTarget.java
Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
    cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java
    cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java
    cocoon/trunk/src/java/org/apache/cocoon/core/BootstrapEnvironment.java
    cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
    cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
    cocoon/trunk/src/test/org/apache/cocoon/test/core/TestBootstrapEnvironment.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/CocoonPortlet.java Thu Jun 30
05:24:57 2005
@@ -63,10 +63,8 @@
 import org.apache.cocoon.portlet.multipart.MultipartActionRequest;
 import org.apache.cocoon.portlet.multipart.RequestFactory;
 import org.apache.cocoon.util.IOUtils;
-import org.apache.cocoon.util.log.CocoonLogFormatter;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.log.ContextMap;
-import org.apache.log.LogTarget;
 
 /**
  * This is the entry point for Cocoon execution as an JSR-168 Portlet.
@@ -859,6 +857,13 @@
         }
 
         /**
+         * @see org.apache.cocoon.core.BootstrapEnvironment#getBootstrapLogger(org.apache.cocoon.core.BootstrapEnvironment.LogLevel)
+         */
+        public Logger getBootstrapLogger(LogLevel logLevel) {
+            return new PortletLogger(this.config.getPortletContext(), logLevel.getLevel());
+        }
+
+        /**
          * @see org.apache.cocoon.core.BootstrapEnvironment#log(java.lang.String)
          */
         public void log(String message) {
@@ -925,16 +930,6 @@
          */
         public File getContextForWriting() {
             return this.writeableContextPath;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getDefaultLogTarget()
-         */
-        public LogTarget getDefaultLogTarget() {
-            final CocoonLogFormatter formatter = new CocoonLogFormatter();
-            formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
-                                "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
-            return new PortletOutputLogTarget(this.config.getPortletContext(), formatter);
         }
 
         /**

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java Thu
Jun 30 05:24:57 2005
@@ -72,6 +72,8 @@
  * first create and initialize an instance of the Cocoon object, and this
  * Portlet will use this instance to process requests.</p>
  *
+ * TODO - Rewrite this to use the CoreUtil!
+ *
  * @version CVS $Id$
  */
 public class ManagedCocoonPortlet extends GenericPortlet {

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java?rev=202547&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java Thu Jun 30
05:24:57 2005
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2005 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
+ * 
+ *      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.
+ */
+package org.apache.cocoon.portlet;
+
+import org.apache.avalon.framework.logger.Logger;
+
+import javax.portlet.PortletContext;
+
+/**
+ * Logger for JSR-168 Portlet context.
+ *
+ * @version SVN $Id$
+ */
+public class PortletLogger implements Logger {
+
+    /** Typecode for debugging messages. */
+    public static final int LEVEL_DEBUG = 0;
+
+    /** Typecode for informational messages. */
+    public static final int LEVEL_INFO = 1;
+
+    /** Typecode for warning messages. */
+    public static final int LEVEL_WARN = 2;
+
+    /** Typecode for error messages. */
+    public static final int LEVEL_ERROR = 3;
+
+    /** Typecode for fatal error messages. */
+    public static final int LEVEL_FATAL = 4;
+
+    /** Typecode for disabled log levels. */
+    public static final int LEVEL_DISABLED = 5;
+
+    private final PortletContext portletContext;
+    private final int logLevel;
+
+    /**
+     * Creates a new Logger with the priority set to DEBUG.
+     */
+    public PortletLogger( final PortletContext servletConfig ) {
+        this( servletConfig, LEVEL_DEBUG );
+    }
+
+    /**
+     * Creates a new Logger.
+     * @param portletContext PortletContext to log messages to
+     * @param logLevel log level typecode
+     */
+    public PortletLogger( final PortletContext portletContext, final int logLevel ) {
+        this.portletContext = portletContext;
+        this.logLevel = logLevel;
+
+        if ( this.portletContext == null ) {
+            throw new NullPointerException( "portletContext" );
+        }
+        if ( this.logLevel < LEVEL_DEBUG || this.logLevel > LEVEL_DISABLED ) {
+            throw new IllegalArgumentException( "Bad logLevel: " + this.logLevel );
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#debug(java.lang.String)
+     */
+    public void debug( final String message ) {
+        debug( message, null );
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#debug(java.lang.String, java.lang.Throwable)
+     */
+    public void debug( final String message, final Throwable throwable ) {
+        if( this.logLevel <= LEVEL_DEBUG ) {
+            this.portletContext.log( "[DEBUG] " + message, throwable );
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#isDebugEnabled()
+     */
+    public boolean isDebugEnabled() {
+        return this.logLevel <= LEVEL_DEBUG;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#info(java.lang.String)
+     */
+    public void info( final String message ) {
+        info( message, null );
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#info(java.lang.String, java.lang.Throwable)
+     */
+    public void info( final String message, final Throwable throwable ) {
+        if( this.logLevel <= LEVEL_INFO ) {
+            this.portletContext.log( "[INFO] " + message, throwable );
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#isInfoEnabled()
+     */
+    public boolean isInfoEnabled() {
+        return this.logLevel <= LEVEL_INFO;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#warn(java.lang.String)
+     */
+    public void warn( final String message ) {
+        warn( message, null );
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#warn(java.lang.String, java.lang.Throwable)
+     */
+    public void warn( final String message, final Throwable throwable ) {
+        if( this.logLevel <= LEVEL_WARN ) {
+            this.portletContext.log( "[WARNING] " + message, throwable );
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#isWarnEnabled()
+     */
+    public boolean isWarnEnabled() {
+        return this.logLevel <= LEVEL_WARN;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#error(java.lang.String)
+     */
+    public void error( final String message ) {
+        error( message, null );
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#error(java.lang.String, java.lang.Throwable)
+     */
+    public void error( final String message, final Throwable throwable ) {
+        if( this.logLevel <= LEVEL_ERROR ) {
+            this.portletContext.log( "[ERROR] " + message, throwable );
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#isErrorEnabled()
+     */
+    public boolean isErrorEnabled() {
+        return this.logLevel <= LEVEL_ERROR;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#fatalError(java.lang.String)
+     */
+    public void fatalError( final String message ) {
+        fatalError( message, null );
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#fatalError(java.lang.String, java.lang.Throwable)
+     */
+    public void fatalError( final String message, final Throwable throwable ) {
+        if( this.logLevel <= LEVEL_FATAL ) {
+            this.portletContext.log( "[FATAL ERROR] " + message, throwable );
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.Logger#isFatalErrorEnabled()
+     */
+    public boolean isFatalErrorEnabled() {
+        return this.logLevel <= LEVEL_FATAL;
+    }
+
+    /**
+     * Just returns this logger (<code>PortletLogger</code> is not hierarchical).
+     *
+     * @param name ignored
+     * @return this logger
+     * @see org.apache.avalon.framework.logger.Logger#getChildLogger(java.lang.String)
+     */
+    public Logger getChildLogger( final String name ) {
+        return this;
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portlet/PortletLogger.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java Thu Jun 30 05:24:57 2005
@@ -32,7 +32,7 @@
 import java.util.TreeMap;
 
 import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.LogKitLogger;
+import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.Cocoon;
@@ -54,9 +54,6 @@
 import org.apache.cocoon.xml.ContentHandlerWrapper;
 import org.apache.cocoon.xml.XMLConsumer;
 import org.apache.commons.lang.SystemUtils;
-import org.apache.log.Hierarchy;
-import org.apache.log.LogTarget;
-import org.apache.log.Priority;
 import org.xml.sax.ContentHandler;
 
 /**
@@ -106,15 +103,9 @@
      * INITIALISATION METHOD.
      */
     public void initialize() throws Exception {
-        // Create a new hierarchy. This is needed when CocoonBean is called from
-        // within a CocoonServlet call, in order not to mix logs
-        final Hierarchy hierarchy = new Hierarchy();
-
-        final Priority priority = Priority.getPriorityForName(logLevel);
-        hierarchy.setDefaultPriority(priority);
-
         // Install a temporary logger so that getDir() can log if needed
-        final Logger envLogger = new LogKitLogger(hierarchy.getLoggerFor(""));
+        final BootstrapEnvironment.LogLevel level = BootstrapEnvironment.LogLevel.getLogLevelForName(this.logLevel);
+        final Logger envLogger = new ConsoleLogger(level.getLevel());
 
         this.context = getDir(this.contextDir, "context");
         this.work = getDir(workDir, "working");
@@ -601,6 +592,13 @@
         protected String configFile;
         protected List loadClassList;
 
+        /**
+         * @see org.apache.cocoon.core.BootstrapEnvironment#getBootstrapLogger(org.apache.cocoon.core.BootstrapEnvironment.LogLevel)
+         */
+        public Logger getBootstrapLogger(LogLevel logLevel) {
+            return new ConsoleLogger(logLevel.getLevel());
+        }
+
         public void setEnvironmentLogger(Logger log) {
             this.environmentLogger = log;
         }
@@ -652,7 +650,6 @@
             settings.setCacheDirectory(this.cachingDirectory);
             settings.setUploadDirectory(this.contextDirectory + "upload-dir");
             settings.setBootstrapLogLevel(this.bootstrapLogLevel);
-            settings.setCreateLogKitHierarchy(true);
             settings.setLoggingConfiguration(this.loggingConfiguration);
             settings.setFormEncoding("ISO-8859-1");
             settings.setConfiguration(this.configFile);
@@ -697,13 +694,6 @@
          */
         public String getContextURL() {
             return this.contextDirectory;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getDefaultLogTarget()
-         */
-        public LogTarget getDefaultLogTarget() {
-            return null;
         }
 
         /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/BaseSettings.java Thu Jun 30 05:24:57 2005
@@ -38,11 +38,6 @@
      */
     boolean INIT_CLASSLOADER = false;
     
-    /**
-     * Default value for {@link #isCreateLogKitHierarchy()} (false)
-     */
-    boolean CREATE_LOGKIT_HIERARCHY = false;
-
     /** Name of the property specifying a user properties file */
     String PROPERTY_USER_SETTINGS = "org.apache.cocoon.settings";
 
@@ -72,13 +67,6 @@
     String KEY_LOGGING_BOOTSTRAP_LOGLEVEL = "logging.bootstrap.loglevel";
 
     /**
-     * Create a new hierarchy for LogKit.
-     * If this is set to true, a new log hierarchy for LogKit is used. Otherwise
-     * the default hierarchy is used.
-     */
-    String KEY_LOGGING_LOGKIT_NEW_HIERARCHY = "logging.logkit.createhierarchy";
-
-    /**
      * This parameter switches the logging system from LogKit to Log4J for Cocoon.
      * Log4J has to be configured already.
      */
@@ -293,11 +281,5 @@
      * @see #KEY_LOGGING_COCOON_LOGGER
      */
     String getCocoonLogger();
-
-    /**
-     * @return Returns true if a new hierarchy should be created
-     * @see #KEY_LOGGING_LOGKIT_NEW_HIERARCHY
-     */
-    boolean isCreateLogKitHierarchy();
 
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/BootstrapEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/BootstrapEnvironment.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/BootstrapEnvironment.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/BootstrapEnvironment.java Thu Jun 30 05:24:57
2005
@@ -22,7 +22,6 @@
 
 import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.avalon.framework.logger.Logger;
-import org.apache.log.LogTarget;
 
 /**
  * The BootstrapEnvironment is the connection between the real environment
@@ -32,13 +31,60 @@
  * A BootstrapEnvironment can be used to create a new Cocoon system using
  * the {@link CoreUtil}.
  * 
- * TODO - Remove dependencies to LogKit
- *
  * @version SVN $Id$
  * @since 2.2
  */
 public interface BootstrapEnvironment {
 
+    public static final class LogLevel {
+
+        public static final LogLevel DEBUG = new LogLevel( "DEBUG", 0 );
+        public static final LogLevel INFO = new LogLevel( "INFO", 1 );
+        public static final LogLevel WARN = new LogLevel( "WARN", 2 );
+        public static final LogLevel ERROR = new LogLevel( "ERROR", 3 );
+        public static final LogLevel FATAL_ERROR = new LogLevel( "FATAL_ERROR", 4 );
+        public static final LogLevel DISABLED = new LogLevel( "NONE", 5 );
+
+        public static LogLevel getLogLevelForName(final String name) {
+            if( DEBUG.getName().equals( name ) ) {
+                return DEBUG;
+            } else if( INFO.getName().equals( name ) ) {
+                return INFO;
+            } else if( WARN.getName().equals( name ) ) {
+                return WARN;
+            } else if( ERROR.getName().equals( name ) ) {
+                return ERROR;
+            } else if( FATAL_ERROR.getName().equals( name ) ) {
+                return FATAL_ERROR;
+            } else if( DISABLED.getName().equals( name ) ) {
+                return DISABLED;
+            } else {
+                return DEBUG;
+            }
+        }    
+
+        private final String name;
+        private final int level;
+
+        public LogLevel(String name, int level) {
+            this.name = name;
+            this.level = level;
+        }
+
+        public int getLevel() {
+            return this.level;
+        }
+
+        public String getName() {
+            return this.name;
+        }
+    }
+    /**
+     * Get the bootstrap logger.
+     * @param logLevel The log level to use according to the {@link Logger} interface.
+     */
+    Logger getBootstrapLogger(LogLevel logLevel);
+
     /** Log a message during bootstrapping. This is used to log
      * information before the logging system is setup.
      * @param message A message.
@@ -98,8 +144,6 @@
      *         writeable.
      */
     File getContextForWriting();
-
-    LogTarget getDefaultLogTarget();
 
     /**
      * Set the ConfigFile for the Cocoon object.

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java Thu Jun 30 05:24:57 2005
@@ -40,7 +40,6 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.LogKitLogger;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
@@ -56,16 +55,12 @@
 import org.apache.cocoon.util.log.Log4JConfigurator;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.TraversableSource;
-import org.apache.log.ErrorHandler;
-import org.apache.log.Hierarchy;
-import org.apache.log.Priority;
-import org.apache.log.util.DefaultErrorHandler;
 import org.apache.log4j.LogManager;
 
 /**
  * This is an utility class to create a new Cocoon instance.
  * 
- * TODO - Remove dependencies to LogKit
+ * TODO - Remove dependencies to LogKit and Log4J
  *
  * @version $Id$
  * @since 2.2
@@ -383,25 +378,13 @@
             accesslogger = "cocoon";
         }
 
-        final Priority logPriority = Priority.getPriorityForName(logLevel);
-
-        final Hierarchy defaultHierarchy;
-        if ( settings.isCreateLogKitHierarchy() ) {
-            defaultHierarchy = new Hierarchy();            
-        } else {
-            defaultHierarchy = Hierarchy.getDefaultHierarchy();
-        }
-        final ErrorHandler errorHandler = new DefaultErrorHandler();
-        defaultHierarchy.setErrorHandler(errorHandler);
-        if ( this.env.getDefaultLogTarget() != null ) {
-            defaultHierarchy.setDefaultLogTarget(this.env.getDefaultLogTarget());
-        }
-        defaultHierarchy.setDefaultPriority(logPriority);
-        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
+        // create bootstrap logger
+        final BootstrapEnvironment.LogLevel level = BootstrapEnvironment.LogLevel.getLogLevelForName(logLevel);
+        final Logger bootstrapLogger = this.env.getBootstrapLogger(level);
 
         // Create our own resolver
         SimpleSourceResolver resolver = new SimpleSourceResolver();
-        resolver.enableLogging(logger);
+        resolver.enableLogging(bootstrapLogger);
         try {
             resolver.contextualize(this.appContext);
         } catch (ContextException ce) {
@@ -422,16 +405,12 @@
         this.env.configureLoggingContext(subcontext);
 
         String loggerManagerClass = settings.getLoggerManagerClassName();
-        if (loggerManagerClass == null) {
-            loggerManagerClass = LogKitLoggerManager.class.getName();
-        }
 
         // the log4j support requires currently that the log4j system is already
         // configured elsewhere
 
-        final LoggerManager loggerManager = newLoggerManager(
-                loggerManagerClass, defaultHierarchy);
-        ContainerUtil.enableLogging(loggerManager, logger);
+        final LoggerManager loggerManager = this.newLoggerManager(loggerManagerClass);
+        ContainerUtil.enableLogging(loggerManager, bootstrapLogger);
 
         try {
             ContainerUtil.contextualize(loggerManager, subcontext);
@@ -537,29 +516,30 @@
 
             ContainerUtil.initialize(loggerManager);
         } catch (Exception e) {
-            errorHandler.error(
+            bootstrapLogger.error(
                     "Could not set up Cocoon Logger, will use screen instead",
-                    e, null);
+                    e);
         }
 
         this.log = this.loggerManager.getLoggerForCategory(accesslogger);
     }
 
-    private LoggerManager newLoggerManager(String loggerManagerClass,
-            Hierarchy hierarchy) {
-        if (loggerManagerClass.equals(LogKitLoggerManager.class.getName())) {
-            return new LogKitLoggerManager(hierarchy);
-        } else if (loggerManagerClass
-                .equals(Log4JLoggerManager.class.getName())
-                || loggerManagerClass.equalsIgnoreCase("LOG4J")) {
-            return new Log4JLoggerManager();
-        } else {
-            try {
-                Class clazz = Class.forName(loggerManagerClass);
-                return (LoggerManager) clazz.newInstance();
-            } catch (Exception e) {
-                return new LogKitLoggerManager(hierarchy);
-            }
+    /**
+     * Create a new logger manager.
+     * @param loggerManagerClass The class name or one of the allowed shortcuts.
+     * @return A new logger manager.
+     */
+    private LoggerManager newLoggerManager(String loggerManagerClass) {
+        if ("LogKit".equalsIgnoreCase(loggerManagerClass) || loggerManagerClass == null)
{
+            loggerManagerClass = LogKitLoggerManager.class.getName();
+        } else if ("LOG4J".equalsIgnoreCase(loggerManagerClass)) {
+            loggerManagerClass = Log4JLoggerManager.class.getName();
+        }
+        try {
+            Class clazz = Class.forName(loggerManagerClass);
+            return (LoggerManager) clazz.newInstance();
+        } catch (Exception e) {
+            return new LogKitLoggerManager();
         }
     }
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/MutableSettings.java Thu Jun 30 05:24:57
2005
@@ -229,8 +229,6 @@
      */
     protected boolean lazyMode = false;
 
-    protected boolean createLogKitHierarchy = CREATE_LOGKIT_HIERARCHY;
-
     /**
      * Create a new settings object
      */
@@ -917,14 +915,4 @@
         }
     }
 
-    /**
-     * @see org.apache.cocoon.core.BaseSettings#isCreateLogKitHierarchy()
-     */
-    public boolean isCreateLogKitHierarchy() {
-        return this.createLogKitHierarchy;
-    }
-
-    public void setCreateLogKitHierarchy(boolean flag) {
-        this.createLogKitHierarchy = flag;
-    }
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java Thu Jun 30 05:24:57
2005
@@ -40,6 +40,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.avalon.excalibur.logger.ServletLogger;
 import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.Cocoon;
@@ -60,12 +61,9 @@
 import org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest;
 import org.apache.cocoon.servlet.multipart.RequestFactory;
 import org.apache.cocoon.util.IOUtils;
-import org.apache.cocoon.util.log.CocoonLogFormatter;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.time.StopWatch;
 import org.apache.log.ContextMap;
-import org.apache.log.LogTarget;
-import org.apache.log.output.ServletOutputLogTarget;
 
 /**
  * This is the entry point for Cocoon execution as an HTTP Servlet.
@@ -660,6 +658,13 @@
         }
 
         /**
+         * @see org.apache.cocoon.core.BootstrapEnvironment#getBootstrapLogger(org.apache.cocoon.core.BootstrapEnvironment.LogLevel)
+         */
+        public Logger getBootstrapLogger(BootstrapEnvironment.LogLevel logLevel) {
+            return new ServletLogger(this.config, logLevel.getLevel());
+        }
+
+        /**
          * @see org.apache.cocoon.core.BootstrapEnvironment#log(java.lang.String)
          */
         public void log(String message) {
@@ -729,17 +734,6 @@
          */
         public File getContextForWriting() {
             return this.writeableContextPath;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getDefaultLogTarget()
-         */
-        public LogTarget getDefaultLogTarget() {
-            final CocoonLogFormatter formatter = new CocoonLogFormatter();
-            formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
-                                "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
-            return new ServletOutputLogTarget(this.config.getServletContext(), formatter);
-
         }
 
         /**

Modified: cocoon/trunk/src/test/org/apache/cocoon/test/core/TestBootstrapEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/test/core/TestBootstrapEnvironment.java?rev=202547&r1=202546&r2=202547&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/test/core/TestBootstrapEnvironment.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/test/core/TestBootstrapEnvironment.java Thu Jun
30 05:24:57 2005
@@ -27,7 +27,6 @@
 import org.apache.cocoon.core.Settings;
 import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.util.log.DeprecationLogger;
-import org.apache.log.LogTarget;
 
 public class TestBootstrapEnvironment
     implements BootstrapEnvironment {
@@ -42,7 +41,7 @@
                                     ClassLoader classLoader,
                                     String contextPath,
                                     Context environmentContext,
-				    Logger logger) {
+				                    Logger logger) {
         this.configuration = configuration;
         this.classLoader = classLoader;
         this.contextPath = contextPath;
@@ -52,6 +51,13 @@
         DeprecationLogger.logger = this.logger;
     }
 
+    /**
+     * @see org.apache.cocoon.core.BootstrapEnvironment#getBootstrapLogger(org.apache.cocoon.core.BootstrapEnvironment.LogLevel)
+     */
+    public Logger getBootstrapLogger(LogLevel logLevel) {
+        return this.logger;
+    }
+
     /** Log a message during bootstrapping. This is used to log
      * information before the logging system is setup.
      * @param message A message.
@@ -127,10 +133,6 @@
      *         writeable.
      */
     public File getContextForWriting() {
-        return null;
-    }
-
-    public LogTarget getDefaultLogTarget() {
         return null;
     }
 



Mime
View raw message