Add LogUtils and HttpLogging

SPR-17012
This commit is contained in:
Rossen Stoyanchev 2018-07-18 09:47:50 -04:00
parent 23d4862017
commit 4d6f2df3cb
22 changed files with 212 additions and 112 deletions

View File

@ -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.
*
* <p>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<Log> 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<Log> 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<Log> loggers = new ArrayList<>(1 + secondaryLoggers.length);
loggers.add(primaryLogger);
Collections.addAll(loggers, secondaryLoggers);
return new HttpLog(loggers);
}
}

View File

@ -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.
* <p>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<Log> 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());
}
}

View File

@ -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;

View File

@ -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.
*
* <p>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}.
*
* <p>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);
}
}

View File

@ -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;

View File

@ -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();

View File

@ -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<T> implements HttpMessageReader<T> {
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);
}
}

View File

@ -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<T> implements HttpMessageWriter<T> {
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);
}
}

View File

@ -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;

View File

@ -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<Resource> {
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;

View File

@ -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;

View File

@ -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<T> implements HttpMessageConverter<T> {
/** Logger available to subclasses. */
protected final Log logger = HttpLog.create(LogFactory.getLog(getClass()));
protected final Log logger = HttpLogging.forLogName(getClass());
private List<MediaType> supportedMediaTypes = Collections.emptyList();

View File

@ -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<?>, Class<?>> mixIns = new HashMap<>();

View File

@ -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<T> implements Publisher<T> {
/**
* Special logger for tracing Reactive Streams signals.
* <p>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> state = new AtomicReference<>(State.UNSUBSCRIBED);

View File

@ -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<T> implements Processor<Publisher<? extends T>, Void> {
/**
* Special logger for tracing Reactive Streams signals.
* <p>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> state = new AtomicReference<>(State.UNSUBSCRIBED);

View File

@ -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<T> implements Processor<T, Void> {
/**
* Special logger for tracing Reactive Streams signals.
* <p>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> state = new AtomicReference<>(State.UNSUBSCRIBED);

View File

@ -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("([^&=]+)(=?)([^&]+)?");

View File

@ -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;

View File

@ -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<HttpServerRequest, HttpServerResponse, Mono<Void>> {
private static final Log logger = HttpLog.create(LogFactory.getLog(ReactorHttpHandlerAdapter.class));
private static final Log logger = HttpLogging.forLogName(ReactorHttpHandlerAdapter.class);
private final HttpHandler httpHandler;

View File

@ -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;

View File

@ -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;

View File

@ -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<Void> {
/**
* Special logger for tracing Reactive Streams signals.
* <p>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> state = new AtomicReference<>(State.UNSUBSCRIBED);