diff --git a/spring-web/src/main/java/org/springframework/http/HttpLog.java b/spring-core/src/main/java/org/springframework/util/log/CompositeLog.java
similarity index 66%
rename from spring-web/src/main/java/org/springframework/http/HttpLog.java
rename to spring-core/src/main/java/org/springframework/util/log/CompositeLog.java
index a24883a7afb..25a1e875e50 100644
--- a/spring-web/src/main/java/org/springframework/http/HttpLog.java
+++ b/spring-core/src/main/java/org/springframework/util/log/CompositeLog.java
@@ -13,36 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.http;
+package org.springframework.util.log;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.NoOpLog;
-import org.springframework.util.ObjectUtils;
-
/**
- * Composite {@link Log} configured with a primary logger and a list of secondary
- * ones to fall back on if the main one is not enabled.
- *
- *
This class also declares {@link #webLogger} for use as fallback when
- * logging in the "org.springframework.http" package.
+ * Implementation of {@link Log} that wraps a list of loggers and delegates to
+ * the first one for which logging is enabled at the given level.
*
* @author Rossen Stoyanchev
* @since 5.1
+ * @see LogUtils#getCompositeLog
*/
-public final class HttpLog implements Log {
-
- /**
- * Logger with category "org.springframework.web.HTTP" to use as fallback
- * if "org.springframework.web" is on.
- */
- public static final Log webLogger = LogFactory.getLog("org.springframework.web.HTTP");
+class CompositeLog implements Log {
private static final Log noOpLog = new NoOpLog();
@@ -60,7 +47,12 @@ public final class HttpLog implements Log {
private final Log traceLogger;
- private HttpLog(List loggers) {
+ /**
+ * Constructor with list of loggers. For optimal performance, the constructor
+ * checks and remembers which logger is on for each log category.
+ * @param loggers the loggers to use
+ */
+ public CompositeLog(List loggers) {
this.fatalLogger = initLogger(loggers, Log::isFatalEnabled);
this.errorLogger = initLogger(loggers, Log::isErrorEnabled);
this.warnLogger = initLogger(loggers, Log::isWarnEnabled);
@@ -163,33 +155,4 @@ public final class HttpLog implements Log {
public void trace(Object message, Throwable ex) {
this.traceLogger.trace(message, ex);
}
-
-
- /**
- * Create a composite logger that uses the given primary logger, if enabled,
- * or falls back on {@link #webLogger}.
- * @param primaryLogger the primary logger
- * @return a composite logger
- */
- public static Log create(Log primaryLogger) {
- return createWith(primaryLogger, webLogger);
- }
-
- /**
- * Create a composite logger that uses the given primary logger, if enabled,
- * or falls back on one of the given secondary loggers..
- * @param primaryLogger the primary logger
- * @param secondaryLoggers fallback loggers
- * @return a composite logger
- */
- public static Log createWith(Log primaryLogger, Log... secondaryLoggers) {
- if (ObjectUtils.isEmpty(secondaryLoggers)) {
- return primaryLogger;
- }
- List loggers = new ArrayList<>(1 + secondaryLoggers.length);
- loggers.add(primaryLogger);
- Collections.addAll(loggers, secondaryLoggers);
- return new HttpLog(loggers);
- }
-
}
diff --git a/spring-core/src/main/java/org/springframework/util/log/LogUtils.java b/spring-core/src/main/java/org/springframework/util/log/LogUtils.java
new file mode 100644
index 00000000000..b4d98c50546
--- /dev/null
+++ b/spring-core/src/main/java/org/springframework/util/log/LogUtils.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2018 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.springframework.util.log;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Utilities to assist with logging. Mainly for internal use within the framework
+ * with Appache Commons Logging.
+ *
+ * @author Rossen Stoyanchev
+ * @since 5.1
+ */
+public abstract class LogUtils {
+
+ /**
+ * Create a composite logger that delegates to a primary or falls back on a
+ * secondary logger if logging for the primary logger is not enabled.
+ * This may be used for fallback logging from lower level packages that
+ * logically should log together with some higher level package but the two
+ * don't happen to share a suitable parent package (e.g. logging for the web
+ * and lower level http and codec packages). For such cases the primary,
+ * class-based logger can be wrapped with a shared fallback logger.
+ * @param primaryLogger primary logger to try first
+ * @param secondaryLogger secondary logger
+ * @param tertiaryLoggers optionally, more fallback loggers
+ * @return the resulting logger to use
+ */
+ public static Log getCompositeLog(Log primaryLogger, Log secondaryLogger, Log... tertiaryLoggers) {
+ List loggers = new ArrayList<>(2 + tertiaryLoggers.length);
+ loggers.add(primaryLogger);
+ loggers.add(secondaryLogger);
+ Collections.addAll(loggers, tertiaryLoggers);
+ return new CompositeLog(loggers);
+ }
+
+ /**
+ * Create a "hidden" logger whose name is intentionally prefixed with "_"
+ * because its output is either too verbose or otherwise deemed as optional
+ * or unnecessary to see at any log level by default under the normal package
+ * based log hierarchy.
+ * @param clazz the class for which to create a logger
+ * @return the created logger
+ */
+ public static Log getHiddenLog(Class> clazz) {
+ return LogFactory.getLog("_" + clazz.getName());
+ }
+
+}
diff --git a/spring-core/src/main/java/org/springframework/util/log/package-info.java b/spring-core/src/main/java/org/springframework/util/log/package-info.java
new file mode 100644
index 00000000000..c476b253ad1
--- /dev/null
+++ b/spring-core/src/main/java/org/springframework/util/log/package-info.java
@@ -0,0 +1,9 @@
+/**
+ * Useful helper classes for logging.
+ */
+@NonNullApi
+@NonNullFields
+package org.springframework.util.log;
+
+import org.springframework.lang.NonNullApi;
+import org.springframework.lang.NonNullFields;
diff --git a/spring-web/src/main/java/org/springframework/http/HttpLogging.java b/spring-web/src/main/java/org/springframework/http/HttpLogging.java
new file mode 100644
index 00000000000..d9e1339b61e
--- /dev/null
+++ b/spring-web/src/main/java/org/springframework/http/HttpLogging.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2002-2018 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.springframework.http;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.springframework.util.log.LogUtils;
+
+/**
+ * Holds the shared logger named "org.springframework.web.HttpLogging" for HTTP
+ * related logging when "org.springframework.http" is not enabled but
+ * "org.springframework.web" is.
+ *
+ * That means "org.springframework.web" enables all web logging including
+ * from lower level packages such as "org.springframework.http" and modules
+ * such as codecs from {@literal "spring-core"} when those are wrapped with
+ * {@link org.springframework.http.codec.EncoderHttpMessageWriter EncoderHttpMessageWriter} or
+ * {@link org.springframework.http.codec.DecoderHttpMessageReader DecoderHttpMessageReader}.
+ *
+ *
To see logging from the primary class loggers simply enable logging for
+ * "org.springframework.http" and "org.springframework.codec".
+ *
+ * @author Rossen Stoyanchev
+ * @since 5.1
+ */
+public abstract class HttpLogging {
+
+ private static final Log fallbackLogger =
+ LogFactory.getLog("org.springframework.web." + HttpLogging.class.getSimpleName());
+
+
+ /**
+ * Create a primary logger for the given class and wrap it with a composite
+ * that delegates to it or to the fallback logger
+ * "org.springframework.web.HttpLogging", if the primary is not enabled.
+ * @param primaryLoggerClass the class for the name of the primary logger
+ * @return the resulting composite logger
+ */
+ public static Log forLogName(Class> primaryLoggerClass) {
+ Log primaryLogger = LogFactory.getLog(primaryLoggerClass);
+ return forLog(primaryLogger);
+ }
+
+ /**
+ * Wrap the given primary logger with a composite logger that delegates to
+ * it or to the fallback logger "org.springframework.web.HttpLogging", if
+ * the primary is not enabled.
+ * @param primaryLogger the primary logger to use
+ * @return the resulting composite logger
+ */
+ public static Log forLog(Log primaryLogger) {
+ return LogUtils.getCompositeLog(primaryLogger, fallbackLogger);
+ }
+
+}
diff --git a/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java b/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java
index e9ebd975dc8..d122fb5321b 100644
--- a/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java
+++ b/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java
@@ -20,8 +20,8 @@ import java.io.IOException;
import java.net.URI;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -44,7 +44,7 @@ import org.springframework.util.Assert;
public class AsyncHttpAccessor {
/** Logger available to subclasses. */
- protected final Log logger = LogFactory.getLog(getClass());
+ protected final Log logger = HttpLogging.forLogName(getClass());
@Nullable
private org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory;
diff --git a/spring-web/src/main/java/org/springframework/http/client/support/HttpAccessor.java b/spring-web/src/main/java/org/springframework/http/client/support/HttpAccessor.java
index 25e7cacf5c3..bdf02ca9b8b 100644
--- a/spring-web/src/main/java/org/springframework/http/client/support/HttpAccessor.java
+++ b/spring-web/src/main/java/org/springframework/http/client/support/HttpAccessor.java
@@ -20,8 +20,8 @@ import java.io.IOException;
import java.net.URI;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
@@ -45,7 +45,7 @@ import org.springframework.util.Assert;
public abstract class HttpAccessor {
/** Logger available to subclasses. */
- protected final Log logger = LogFactory.getLog(getClass());
+ protected final Log logger = HttpLogging.forLogName(getClass());
private ClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
diff --git a/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java
index 540c7c9fed6..8f1a6179282 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java
@@ -27,7 +27,7 @@ import org.springframework.core.ResolvableType;
import org.springframework.core.codec.AbstractDecoder;
import org.springframework.core.codec.Decoder;
import org.springframework.core.codec.Hints;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpMessage;
import org.springframework.http.MediaType;
import org.springframework.http.ReactiveHttpInputMessage;
@@ -70,7 +70,7 @@ public class DecoderHttpMessageReader implements HttpMessageReader {
if (decoder instanceof AbstractDecoder &&
decoder.getClass().getPackage().getName().startsWith("org.springframework.core.codec")) {
- Log logger = HttpLog.create(((AbstractDecoder) decoder).getLogger());
+ Log logger = HttpLogging.forLog(((AbstractDecoder) decoder).getLogger());
((AbstractDecoder) decoder).setLogger(logger);
}
}
diff --git a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java
index 16a8d5660e9..f7f2ce6109c 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java
@@ -30,7 +30,7 @@ import org.springframework.core.codec.Encoder;
import org.springframework.core.codec.Hints;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.MediaType;
import org.springframework.http.ReactiveHttpOutputMessage;
import org.springframework.http.server.reactive.ServerHttpRequest;
@@ -76,7 +76,7 @@ public class EncoderHttpMessageWriter implements HttpMessageWriter {
if (encoder instanceof AbstractEncoder &&
encoder.getClass().getPackage().getName().startsWith("org.springframework.core.codec")) {
- Log logger = HttpLog.create(((AbstractEncoder) encoder).getLogger());
+ Log logger = HttpLogging.forLog(((AbstractEncoder) encoder).getLogger());
((AbstractEncoder) encoder).setLogger(logger);
}
}
diff --git a/spring-web/src/main/java/org/springframework/http/codec/LoggingCodecSupport.java b/spring-web/src/main/java/org/springframework/http/codec/LoggingCodecSupport.java
index 934e86520e8..bb62921086b 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/LoggingCodecSupport.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/LoggingCodecSupport.java
@@ -16,9 +16,8 @@
package org.springframework.http.codec;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
/**
* Base class for {@link org.springframework.core.codec.Encoder},
@@ -31,7 +30,7 @@ import org.springframework.http.HttpLog;
*/
public class LoggingCodecSupport {
- protected final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
+ protected final Log logger = HttpLogging.forLogName(getClass());
/** Whether to log potentially sensitive info (form data at DEBUG and headers at TRACE). */
private boolean enableLoggingRequestDetails = false;
diff --git a/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java
index 2ea4f0965f8..1f78c77734f 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java
@@ -23,7 +23,6 @@ import java.util.Map;
import java.util.Optional;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -39,7 +38,7 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.support.ResourceRegion;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpRange;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -73,7 +72,7 @@ public class ResourceHttpMessageWriter implements HttpMessageWriter {
private static final ResolvableType REGION_TYPE = ResolvableType.forClass(ResourceRegion.class);
- private static final Log logger = HttpLog.create(LogFactory.getLog(ResourceHttpMessageWriter.class));
+ private static final Log logger = HttpLogging.forLogName(ResourceHttpMessageWriter.class);
private final ResourceEncoder encoder;
diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java
index 3835053add1..ff3efa860cc 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java
@@ -29,13 +29,12 @@ import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.Hints;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
@@ -66,7 +65,7 @@ public abstract class Jackson2CodecSupport {
new MimeType("application", "*+json", StandardCharsets.UTF_8)));
- protected final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
+ protected final Log logger = HttpLogging.forLogName(getClass());
private final ObjectMapper objectMapper;
diff --git a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java
index 49bc4e1564b..75a5477782e 100644
--- a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java
+++ b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java
@@ -25,11 +25,10 @@ import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.StreamingHttpOutputMessage;
@@ -52,7 +51,7 @@ import org.springframework.util.Assert;
public abstract class AbstractHttpMessageConverter implements HttpMessageConverter {
/** Logger available to subclasses. */
- protected final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
+ protected final Log logger = HttpLogging.forLogName(getClass());
private List supportedMediaTypes = Collections.emptyList();
diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
index 0ba3b93519f..c7c8cba2170 100644
--- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
+++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
@@ -54,13 +54,12 @@ import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
import com.fasterxml.jackson.dataformat.xml.XmlFactory;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.FatalBeanException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.KotlinDetector;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -104,7 +103,7 @@ public class Jackson2ObjectMapperBuilder {
private static volatile boolean kotlinWarningLogged = false;
- private final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
+ private final Log logger = HttpLogging.forLogName(getClass());
private final Map, Class>> mixIns = new HashMap<>();
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java
index a597a0f1426..680b463ccc4 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java
@@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
@@ -29,6 +28,7 @@ import reactor.core.publisher.Operators;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
+import org.springframework.util.log.LogUtils;
/**
* Abstract base class for {@code Publisher} implementations that bridge between
@@ -48,12 +48,13 @@ import org.springframework.util.Assert;
public abstract class AbstractListenerReadPublisher implements Publisher {
/**
- * Special logger for tracing Reactive Streams signals.
- * This logger is not exposed under "org.springframework" because it is
- * verbose. To enable this, and other related Reactive Streams loggers in
- * this package, set "spring-web.reactivestreams" to TRACE.
+ * Special logger for debugging Reactive Streams signals.
+ * @see LogUtils#getHiddenLog(Class)
+ * @see AbstractListenerWriteProcessor#rsWriteLogger
+ * @see AbstractListenerWriteFlushProcessor#rsWriteFlushLogger
+ * @see WriteResultPublisher#rsWriteResultLogger
*/
- protected static Log rsReadLogger = LogFactory.getLog("spring-web.reactivestreams.ReadPublisher");
+ protected static Log rsReadLogger = LogUtils.getHiddenLog(AbstractListenerReadPublisher.class);
private final AtomicReference state = new AtomicReference<>(State.UNSUBSCRIBED);
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java
index d3f512a9fbf..ff6fe758bd1 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Processor;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
@@ -28,6 +27,7 @@ import org.reactivestreams.Subscription;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
+import org.springframework.util.log.LogUtils;
/**
* An alternative to {@link AbstractListenerWriteProcessor} but instead writing
@@ -43,13 +43,13 @@ import org.springframework.util.Assert;
public abstract class AbstractListenerWriteFlushProcessor implements Processor, Void> {
/**
- * Special logger for tracing Reactive Streams signals.
- * This logger is not exposed under "org.springframework" because it is
- * verbose. To enable this, and other related Reactive Streams loggers in
- * this package, set "spring-web.reactivestreams" to TRACE.
+ * Special logger for debugging Reactive Streams signals.
+ * @see LogUtils#getHiddenLog(Class)
+ * @see AbstractListenerReadPublisher#rsReadLogger
+ * @see AbstractListenerWriteProcessor#rsWriteLogger
+ * @see WriteResultPublisher#rsWriteResultLogger
*/
- protected static final Log rsWriteFlushLogger =
- LogFactory.getLog("spring-web.reactivestreams.WriteFlushProcessor");
+ protected static final Log rsWriteFlushLogger = LogUtils.getHiddenLog(AbstractListenerWriteFlushProcessor.class);
private final AtomicReference state = new AtomicReference<>(State.UNSUBSCRIBED);
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java
index 21f67bc74ce..0be854e4686 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java
@@ -20,13 +20,13 @@ import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Processor;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
+import org.springframework.util.log.LogUtils;
/**
* Abstract base class for {@code Processor} implementations that bridge between
@@ -45,12 +45,13 @@ import org.springframework.util.Assert;
public abstract class AbstractListenerWriteProcessor implements Processor {
/**
- * Special logger for tracing Reactive Streams signals.
- * This logger is not exposed under "org.springframework" because it is
- * verbose. To enable this, and other related Reactive Streams loggers in
- * this package, set "spring-web.reactivestreams" to TRACE.
+ * Special logger for debugging Reactive Streams signals.
+ * @see LogUtils#getHiddenLog(Class)
+ * @see AbstractListenerReadPublisher#rsReadLogger
+ * @see AbstractListenerWriteFlushProcessor#rsWriteFlushLogger
+ * @see WriteResultPublisher#rsWriteResultLogger
*/
- protected static final Log rsWriteLogger = LogFactory.getLog("spring-web.reactivestreams.WriteProcessor");
+ protected static final Log rsWriteLogger = LogUtils.getHiddenLog(AbstractListenerWriteProcessor.class);
private final AtomicReference state = new AtomicReference<>(State.UNSUBSCRIBED);
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpRequest.java
index 8fb17053280..1d8a83c1937 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpRequest.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpRequest.java
@@ -23,11 +23,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpCookie;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.server.RequestPath;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
@@ -44,7 +43,7 @@ import org.springframework.util.StringUtils;
*/
public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
- protected final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
+ protected final Log logger = HttpLogging.forLogName(getClass());
private static final Pattern QUERY_PATTERN = Pattern.compile("([^&=]+)(=?)([^&]+)?");
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java
index 1bc238749cf..2b21a2ef4d3 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java
@@ -23,7 +23,6 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -31,7 +30,7 @@ import reactor.core.publisher.Mono;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import org.springframework.lang.Nullable;
@@ -58,7 +57,7 @@ public abstract class AbstractServerHttpResponse implements ServerHttpResponse {
*/
private enum State {NEW, COMMITTING, COMMITTED}
- protected final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
+ protected final Log logger = HttpLogging.forLogName(getClass());
private final DataBufferFactory dataBufferFactory;
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorHttpHandlerAdapter.java
index 118228f2551..f36422a83db 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorHttpHandlerAdapter.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorHttpHandlerAdapter.java
@@ -21,13 +21,12 @@ import java.util.function.BiFunction;
import io.netty.handler.codec.http.HttpResponseStatus;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Mono;
import reactor.netty.http.server.HttpServerRequest;
import reactor.netty.http.server.HttpServerResponse;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
@@ -40,7 +39,7 @@ import org.springframework.util.Assert;
*/
public class ReactorHttpHandlerAdapter implements BiFunction> {
- private static final Log logger = HttpLog.create(LogFactory.getLog(ReactorHttpHandlerAdapter.class));
+ private static final Log logger = HttpLogging.forLogName(ReactorHttpHandlerAdapter.class);
private final HttpHandler httpHandler;
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java
index 7a2dc13f9b9..93c6ae610fb 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java
@@ -35,13 +35,12 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -58,7 +57,7 @@ import org.springframework.util.Assert;
@SuppressWarnings("serial")
public class ServletHttpHandlerAdapter implements Servlet {
- private static final Log logger = HttpLog.create(LogFactory.getLog(ServletHttpHandlerAdapter.class));
+ private static final Log logger = HttpLogging.forLogName(ServletHttpHandlerAdapter.class);
private static final int DEFAULT_BUFFER_SIZE = 8192;
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowHttpHandlerAdapter.java
index 12323a280f0..28498176dec 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowHttpHandlerAdapter.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowHttpHandlerAdapter.java
@@ -21,13 +21,12 @@ import java.net.URISyntaxException;
import io.undertow.server.HttpServerExchange;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
-import org.springframework.http.HttpLog;
+import org.springframework.http.HttpLogging;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
@@ -41,7 +40,7 @@ import org.springframework.util.Assert;
*/
public class UndertowHttpHandlerAdapter implements io.undertow.server.HttpHandler {
- private static final Log logger = HttpLog.create(LogFactory.getLog(UndertowHttpHandlerAdapter.class));
+ private static final Log logger = HttpLogging.forLogName(UndertowHttpHandlerAdapter.class);
private final HttpHandler httpHandler;
diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java b/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java
index 384e6b01d6f..cbfe6ff7c62 100644
--- a/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java
+++ b/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java
@@ -19,7 +19,6 @@ package org.springframework.http.server.reactive;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
@@ -27,6 +26,7 @@ import reactor.core.publisher.Operators;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
+import org.springframework.util.log.LogUtils;
/**
* Publisher returned from {@link ServerHttpResponse#writeWith(Publisher)}.
@@ -39,13 +39,13 @@ import org.springframework.util.Assert;
class WriteResultPublisher implements Publisher {
/**
- * Special logger for tracing Reactive Streams signals.
- * This logger is not exposed under "org.springframework" because it is
- * verbose. To enable this, and other related Reactive Streams loggers in
- * this package, set "spring-web.reactivestreams" to TRACE.
+ * Special logger for debugging Reactive Streams signals.
+ * @see LogUtils#getHiddenLog(Class)
+ * @see AbstractListenerReadPublisher#rsReadLogger
+ * @see AbstractListenerWriteProcessor#rsWriteLogger
+ * @see AbstractListenerWriteFlushProcessor#rsWriteFlushLogger
*/
- private static final Log rsWriteResultLogger =
- LogFactory.getLog("spring-web.reactivestreams.WriteResultPublisher");
+ private static final Log rsWriteResultLogger = LogUtils.getHiddenLog(WriteResultPublisher.class);
private final AtomicReference state = new AtomicReference<>(State.UNSUBSCRIBED);