diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/Log.java b/spring-jcl/src/main/java/org/apache/commons/logging/Log.java index 5c5523d5a19..2f2b6f9eaac 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/Log.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/Log.java @@ -22,8 +22,8 @@ package org.apache.commons.logging; * instantiated successfully by {@link LogFactory}, classes that implement * this interface must have a constructor that takes a single String * parameter representing the "name" of this Log. - *
- * The six logging levels used by Log are (in order):
+ *
+ *
The six logging levels used by Log are (in order):
*
- * Performance is often a logging concern. + * + *
Performance is often a logging concern. * By examining the appropriate property, * a component can avoid expensive operations (producing information * to be logged). - *
- * For example, + * + *
For example, *
* if (log.isDebugEnabled()) {
* ... do something expensive ...
* log.debug(theResult);
* }
*
- * - * Configuration of the underlying logging system will generally be done + * + *
Configuration of the underlying logging system will generally be done * external to the Logging APIs, through whatever mechanism is supported by * that system. * - * @version $Id: Log.java 1606045 2014-06-27 12:11:56Z tn $ + * @author Juergen Hoeller (for the {@code spring-jcl} variant) + * @since 5.0 */ public interface Log { - /** - * Logs a message with debug log level. - * - * @param message log this message - */ - void debug(Object message); - - /** - * Logs an error with debug log level. - * - * @param message log this message - * @param t log this cause - */ - void debug(Object message, Throwable t); - - /** + /** + * Is fatal logging currently enabled? + *
Call this method to prevent having to perform expensive operations
+ * (for example, String concatenation)
+ * when the log level is more than fatal.
+ * @return true if fatal is enabled in the underlying logger.
+ */
+ boolean isFatalEnabled();
+
+ /**
+ * Is error logging currently enabled?
+ *
Call this method to prevent having to perform expensive operations
+ * (for example, String concatenation)
+ * when the log level is more than error.
+ * @return true if error is enabled in the underlying logger.
+ */
+ boolean isErrorEnabled();
+
+ /**
+ * Is warn logging currently enabled?
+ *
Call this method to prevent having to perform expensive operations
+ * (for example, String concatenation)
+ * when the log level is more than warn.
+ * @return true if warn is enabled in the underlying logger.
+ */
+ boolean isWarnEnabled();
+
+ /**
+ * Is info logging currently enabled?
+ *
Call this method to prevent having to perform expensive operations
+ * (for example, String concatenation)
+ * when the log level is more than info.
+ * @return true if info is enabled in the underlying logger.
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Is debug logging currently enabled?
+ *
Call this method to prevent having to perform expensive operations
+ * (for example, String concatenation)
+ * when the log level is more than debug.
+ * @return true if debug is enabled in the underlying logger.
+ */
+ boolean isDebugEnabled();
+
+ /**
+ * Is trace logging currently enabled?
+ *
Call this method to prevent having to perform expensive operations
+ * (for example, String concatenation)
+ * when the log level is more than trace.
+ * @return true if trace is enabled in the underlying logger.
+ */
+ boolean isTraceEnabled();
+
+
+ /**
+ * Logs a message with fatal log level.
+ * @param message log this message
+ */
+ void fatal(Object message);
+
+ /**
+ * Logs an error with fatal log level.
+ * @param message log this message
+ * @param t log this cause
+ */
+ void fatal(Object message, Throwable t);
+
+ /**
* Logs a message with error log level.
- *
* @param message log this message
*/
void error(Object message);
/**
* Logs an error with error log level.
- *
* @param message log this message
* @param t log this cause
*/
void error(Object message, Throwable t);
- /**
- * Logs a message with fatal log level.
- *
- * @param message log this message
- */
- void fatal(Object message);
+ /**
+ * Logs a message with warn log level.
+ * @param message log this message
+ */
+ void warn(Object message);
- /**
- * Logs an error with fatal log level.
- *
- * @param message log this message
- * @param t log this cause
- */
- void fatal(Object message, Throwable t);
+ /**
+ * Logs an error with warn log level.
+ * @param message log this message
+ * @param t log this cause
+ */
+ void warn(Object message, Throwable t);
/**
* Logs a message with info log level.
- *
* @param message log this message
*/
void info(Object message);
/**
* Logs an error with info log level.
- *
* @param message log this message
* @param t log this cause
*/
void info(Object message, Throwable t);
- /**
- * Is debug logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than debug.
- *
- * @return true if debug is enabled in the underlying logger.
- */
- boolean isDebugEnabled();
+ /**
+ * Logs a message with debug log level.
+ * @param message log this message
+ */
+ void debug(Object message);
- /**
- * Is error logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than error.
- *
- * @return true if error is enabled in the underlying logger.
- */
- boolean isErrorEnabled();
-
- /**
- * Is fatal logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than fatal.
- *
- * @return true if fatal is enabled in the underlying logger.
- */
- boolean isFatalEnabled();
-
- /**
- * Is info logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than info.
- *
- * @return true if info is enabled in the underlying logger.
- */
- boolean isInfoEnabled();
-
- /**
- * Is trace logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than trace.
- *
- * @return true if trace is enabled in the underlying logger.
- */
- boolean isTraceEnabled();
+ /**
+ * Logs an error with debug log level.
+ * @param message log this message
+ * @param t log this cause
+ */
+ void debug(Object message, Throwable t);
- /**
- * Is warn logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than warn.
- *
- * @return true if warn is enabled in the underlying logger.
- */
- boolean isWarnEnabled();
-
- /**
+ /**
* Logs a message with trace log level.
- *
* @param message log this message
*/
void trace(Object message);
/**
* Logs an error with trace log level.
- *
* @param message log this message
* @param t log this cause
*/
void trace(Object message, Throwable t);
- /**
- * Logs a message with warn log level.
- *
- * @param message log this message
- */
- void warn(Object message);
-
- /**
- * Logs an error with warn log level.
- *
- * @param message log this message
- * @param t log this cause
- */
- void warn(Object message, Throwable t);
}
diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java b/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java
index 046b6983bf5..96afa00f496 100644
--- a/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -57,7 +57,7 @@ import org.slf4j.spi.LocationAwareLogger;
* (or another SLF4J provider) onto your classpath, without any extra bridges,
* and let the framework auto-adapt to your choice.
*
- * @author Juergen Hoeller
+ * @author Juergen Hoeller (for the {@code spring-jcl} variant)
* @since 5.0
*/
public abstract class LogFactory {
diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/impl/NoOpLog.java b/spring-jcl/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
new file mode 100644
index 00000000000..6ff00151e6f
--- /dev/null
+++ b/spring-jcl/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2002-2017 the original author or authors.
+ *
+ * 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.commons.logging.impl;
+
+import java.io.Serializable;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Trivial implementation of {@link Log} that throws away all messages.
+ *
+ * @author Juergen Hoeller (for the {@code spring-jcl} variant)
+ * @since 5.0
+ */
+@SuppressWarnings("serial")
+public class NoOpLog implements Log, Serializable {
+
+ public NoOpLog() {
+ }
+
+ public NoOpLog(String name) {
+ }
+
+
+ @Override
+ public boolean isFatalEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return false;
+ }
+
+ @Override
+ public void fatal(Object message) {
+ }
+
+ @Override
+ public void fatal(Object message, Throwable t) {
+ }
+
+ @Override
+ public void error(Object message) {
+ }
+
+ @Override
+ public void error(Object message, Throwable t) {
+ }
+
+ @Override
+ public void warn(Object message) {
+ }
+
+ @Override
+ public void warn(Object message, Throwable t) {
+ }
+
+ @Override
+ public void info(Object message) {
+ }
+
+ @Override
+ public void info(Object message, Throwable t) {
+ }
+
+ @Override
+ public void debug(Object message) {
+ }
+
+ @Override
+ public void debug(Object message, Throwable t) {
+ }
+
+ @Override
+ public void trace(Object message) {
+ }
+
+ @Override
+ public void trace(Object message, Throwable t) {
+ }
+
+}
diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/spring-jcl/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
new file mode 100644
index 00000000000..d33391f2c68
--- /dev/null
+++ b/spring-jcl/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2002-2017 the original author or authors.
+ *
+ * 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.commons.logging.impl;
+
+/**
+ * Originally a simple Commons Logging provider configured by system properties.
+ * Deprecated in {@code spring-jcl}, effectively equivalent to {@link NoOpLog} now.
+ *
+ *
Instead of instantiating this directly, call {@code LogFactory#getLog(Class/String)} + * which will fall back to {@code java.util.logging} if neither Log4j nor SLF4J are present. + * + * @author Juergen Hoeller (for the {@code spring-jcl} variant) + * @since 5.0 + */ +@Deprecated +@SuppressWarnings("serial") +public class SimpleLog extends NoOpLog { + + public SimpleLog(String name) { + super(name); + System.out.println(SimpleLog.class.getName() + " is deprecated and equivalent to NoOpLog in spring-jcl. " + + "Use a standard LogFactory.getLog(Class/String) call instead."); + } + +} diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/impl/package-info.java b/spring-jcl/src/main/java/org/apache/commons/logging/impl/package-info.java new file mode 100644 index 00000000000..e8f429e2915 --- /dev/null +++ b/spring-jcl/src/main/java/org/apache/commons/logging/impl/package-info.java @@ -0,0 +1,11 @@ +/** + * Spring's variant of the + * Commons Logging API: + * with special support for Log4J 2, SLF4J and {@code java.util.logging}. + * + *
This {@code impl} package is only present for binary compatibility + * with existing Commons Logging usage, e.g. in Commons Configuration. + * {@code NoOpLog} can be used as a {@code Log} fallback instance, and + * {@code SimpleLog} is not meant to work (issuing a warning when used). + */ +package org.apache.commons.logging.impl; diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/package-info.java b/spring-jcl/src/main/java/org/apache/commons/logging/package-info.java index bd070b69e44..749d860cc41 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/package-info.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/package-info.java @@ -10,7 +10,7 @@ * or {@code java.util.logging}, with no extra bridge jars necessary, and * also easier setup of SLF4J with Logback (no JCL exclude, no JCL bridge). * - *
{@link org.apache.commons.logging.Log} is an unmodified repackaging. + *
{@link org.apache.commons.logging.Log} is equivalent to the original. * However, {@link org.apache.commons.logging.LogFactory} is a very different * implementation which is minimized and optimized for Spring's purposes, * detecting Log4J 2.x and SLF4J 1.7 in the framework classpath and falling