Author: tv
Date: Thu Feb 28 19:11:36 2019
New Revision: 1854544
URL: http://svn.apache.org/viewvc?rev=1854544&view=rev
Log:
Direct Avalon logging to Log4j2
Added:
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
(with props)
Modified:
turbine/core/trunk/src/changes/changes.xml
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/TurbineYaafiComponentService.java
Modified: turbine/core/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/changes/changes.xml?rev=1854544&r1=1854543&r2=1854544&view=diff
==============================================================================
--- turbine/core/trunk/src/changes/changes.xml (original)
+++ turbine/core/trunk/src/changes/changes.xml Thu Feb 28 19:11:36 2019
@@ -26,6 +26,9 @@
<body>
<release version="5.0" date="in Subversion">
<action type="update" dev="tv">
+ Direct Avalon logging to Log4j2
+ </action>
+ <action type="update" dev="tv">
Update jython to jython-standalone 2.7.1
</action>
<action type="update" dev="tv">
Added:
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java?rev=1854544&view=auto
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
(added)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
Thu Feb 28 19:11:36 2019
@@ -0,0 +1,244 @@
+package org.apache.turbine.services.avaloncomponent;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.logging.log4j.LogManager;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/**
+ * A Log4J2 wrapper class for Logger.
+ *
+ * @author <a href="mailto:[email protected]">Thomas Vandahl</a>
+ */
+public final class Log4j2Logger
+ implements Logger
+{
+ // underlying implementation
+ private final org.apache.logging.log4j.Logger m_logger;
+
+ /**
+ * Create a logger that delegates to specified category.
+ *
+ * @param logImpl
+ * the category to delegate to
+ */
+ public Log4j2Logger(final org.apache.logging.log4j.Logger logImpl)
+ {
+ m_logger = logImpl;
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message
+ * the message
+ */
+ @Override
+ public final void debug(final String message)
+ {
+ m_logger.debug(message);
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message
+ * the message
+ * @param throwable
+ * the throwable
+ */
+ @Override
+ public final void debug(final String message, final Throwable throwable)
+ {
+ m_logger.debug(message, throwable);
+ }
+
+ /**
+ * Determine if messages of priority "debug" will be logged.
+ *
+ * @return true if "debug" messages will be logged
+ */
+ @Override
+ public final boolean isDebugEnabled()
+ {
+ return m_logger.isDebugEnabled();
+ }
+
+ /**
+ * Log a info message.
+ *
+ * @param message
+ * the message
+ */
+ @Override
+ public final void info(final String message)
+ {
+ m_logger.info(message);
+ }
+
+ /**
+ * Log a info message.
+ *
+ * @param message
+ * the message
+ * @param throwable
+ * the throwable
+ */
+ @Override
+ public final void info(final String message, final Throwable throwable)
+ {
+ m_logger.info(message, throwable);
+ }
+
+ /**
+ * Determine if messages of priority "info" will be logged.
+ *
+ * @return true if "info" messages will be logged
+ */
+ @Override
+ public final boolean isInfoEnabled()
+ {
+ return m_logger.isInfoEnabled();
+ }
+
+ /**
+ * Log a warn message.
+ *
+ * @param message
+ * the message
+ */
+ @Override
+ public final void warn(final String message)
+ {
+ m_logger.warn(message);
+ }
+
+ /**
+ * Log a warn message.
+ *
+ * @param message
+ * the message
+ * @param throwable
+ * the throwable
+ */
+ @Override
+ public final void warn(final String message, final Throwable throwable)
+ {
+ m_logger.warn(message, throwable);
+ }
+
+ /**
+ * Determine if messages of priority "warn" will be logged.
+ *
+ * @return true if "warn" messages will be logged
+ */
+ @Override
+ public final boolean isWarnEnabled()
+ {
+ return m_logger.isWarnEnabled();
+ }
+
+ /**
+ * Log a error message.
+ *
+ * @param message
+ * the message
+ */
+ @Override
+ public final void error(final String message)
+ {
+ m_logger.error(message);
+ }
+
+ /**
+ * Log a error message.
+ *
+ * @param message
+ * the message
+ * @param throwable
+ * the throwable
+ */
+ @Override
+ public final void error(final String message, final Throwable throwable)
+ {
+ m_logger.error(message, throwable);
+ }
+
+ /**
+ * Determine if messages of priority "error" will be logged.
+ *
+ * @return true if "error" messages will be logged
+ */
+ @Override
+ public final boolean isErrorEnabled()
+ {
+ return m_logger.isErrorEnabled();
+ }
+
+ /**
+ * Log a fatalError message.
+ *
+ * @param message
+ * the message
+ */
+ @Override
+ public final void fatalError(final String message)
+ {
+ m_logger.fatal(message);
+ }
+
+ /**
+ * Log a fatalError message.
+ *
+ * @param message
+ * the message
+ * @param throwable
+ * the throwable
+ */
+ @Override
+ public final void fatalError(final String message, final Throwable
throwable)
+ {
+ m_logger.fatal(message, throwable);
+ }
+
+ /**
+ * Determine if messages of priority "fatalError" will be logged.
+ *
+ * @return true if "fatalError" messages will be logged
+ */
+ @Override
+ public final boolean isFatalErrorEnabled()
+ {
+ return m_logger.isFatalEnabled();
+ }
+
+ /**
+ * Create a new child logger. The name of the child logger is
+ * [current-loggers-name].[passed-in-name] Throws
+ * <code>IllegalArgumentException</code> if name has an empty element name
+ *
+ * @param name
+ * the subname of this logger
+ * @return the new logger
+ */
+ @Override
+ public final Logger getChildLogger(final String name)
+ {
+ return new Log4j2Logger(LogManager.getLogger(m_logger.getName() + "."
+ name));
+ }
+}
Propchange:
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/TurbineYaafiComponentService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/TurbineYaafiComponentService.java?rev=1854544&r1=1854543&r2=1854544&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/TurbineYaafiComponentService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/TurbineYaafiComponentService.java
Thu Feb 28 19:11:36 2019
@@ -24,15 +24,13 @@ import java.io.IOException;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.logger.CommonsLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.commons.configuration2.Configuration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
import
org.apache.fulcrum.yaafi.framework.factory.ServiceContainerConfiguration;
import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
+import org.apache.logging.log4j.LogManager;
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.InstantiationException;
import org.apache.turbine.services.TurbineBaseService;
@@ -47,7 +45,7 @@ public class TurbineYaafiComponentServic
implements AvalonComponentService, Initializable, Disposable
{
/** the logger to be used */
- private static Log log = LogFactory.getLog(AVALON_LOG_CATEGORY);
+ private static org.apache.logging.log4j.Logger log =
LogManager.getLogger(AVALON_LOG_CATEGORY);
/** property to lookup the container configuration file */
public static final String CONTAINER_CONFIGURATION_KEY =
"containerConfiguration";
@@ -260,8 +258,7 @@ public class TurbineYaafiComponentServic
*/
protected Logger createAvalonLogger()
{
- Logger result = new CommonsLogger(log, AVALON_LOG_CATEGORY);
- return result;
+ return new Log4j2Logger(log);
}
// -------------------------------------------------------------