Refine logging for async requests
Issue: SPR-16898
This commit is contained in:
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||
@@ -94,7 +95,8 @@ public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
|
||||
(GenericHttpMessageConverter<?>) messageConverter;
|
||||
if (genericMessageConverter.canRead(this.responseType, null, contentType)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Reading [" + this.responseType + "]");
|
||||
ResolvableType resolvableType = ResolvableType.forType(this.responseType);
|
||||
logger.debug("Reading to [" + resolvableType + "]");
|
||||
}
|
||||
return (T) genericMessageConverter.read(this.responseType, null, responseWrapper);
|
||||
}
|
||||
@@ -103,7 +105,7 @@ public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
|
||||
if (messageConverter.canRead(this.responseClass, contentType)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
String className = this.responseClass.getName();
|
||||
logger.debug("Reading [" + className + "] as \"" + contentType + "\"");
|
||||
logger.debug("Reading to [" + className + "] as \"" + contentType + "\"");
|
||||
}
|
||||
return (T) messageConverter.read((Class) this.responseClass, responseWrapper);
|
||||
}
|
||||
|
||||
@@ -345,13 +345,14 @@ public final class WebAsyncManager {
|
||||
|
||||
if (this.asyncWebRequest.isAsyncComplete()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Async request already complete for " + formatRequestUri());
|
||||
logger.debug("Async result set but request already complete: " + formatRequestUri());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Async result ready, dispatch to " + formatRequestUri());
|
||||
boolean isError = result instanceof Throwable;
|
||||
logger.debug("Async " + (isError ? "error" : "result set") + ", dispatch to " + formatRequestUri());
|
||||
}
|
||||
this.asyncWebRequest.dispatch();
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ public abstract class CommonsFileUploadSupport {
|
||||
// multipart file field
|
||||
CommonsMultipartFile file = createMultipartFile(fileItem);
|
||||
multipartFiles.add(file.getName(), file);
|
||||
if (logger.isDebugEnabled() || logger.isTraceEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
String message = "Part '" + file.getName() + "', " +
|
||||
"size " + file.getSize() + " bytes, filename='" + file.getOriginalFilename() + "'";
|
||||
if (logger.isTraceEnabled()) {
|
||||
@@ -323,7 +323,7 @@ public abstract class CommonsFileUploadSupport {
|
||||
if (file instanceof CommonsMultipartFile) {
|
||||
CommonsMultipartFile cmf = (CommonsMultipartFile) file;
|
||||
cmf.getFileItem().delete();
|
||||
if (logger.isDebugEnabled() || logger.isTraceEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
String filename = cmf.getOriginalFilename();
|
||||
String message = "Cleaning up part '" + cmf.getName() + "', filename '" + filename + "'";
|
||||
if (logger.isTraceEnabled()) {
|
||||
|
||||
@@ -165,7 +165,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
||||
|
||||
try {
|
||||
this.fileItem.write(dest);
|
||||
if (logger.isDebugEnabled() || logger.isTraceEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
String action = "transferred";
|
||||
if (!this.fileItem.isInMemory()) {
|
||||
action = (isAvailable() ? "copied" : "moved");
|
||||
|
||||
@@ -194,7 +194,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
|
||||
* complete initialization.
|
||||
*/
|
||||
public void afterPropertiesSet() {
|
||||
if (logger.isDebugEnabled() || logger.isTraceEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (this.disableLoggingRequestDetails) {
|
||||
logger.debug("Logging query, form data, multipart data, and headers is OFF.");
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
|
||||
}
|
||||
|
||||
private void logExchange(ServerWebExchange exchange) {
|
||||
if (logger.isDebugEnabled() || logger.isTraceEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
if (logger.isTraceEnabled()) {
|
||||
String headers = this.disableLoggingRequestDetails ? "" : ", headers=" + request.getHeaders();
|
||||
@@ -246,11 +246,11 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
|
||||
String rawQuery = request.getURI().getRawQuery();
|
||||
query = StringUtils.hasText(rawQuery) ? "?" + rawQuery : "";
|
||||
}
|
||||
return "HTTP " + request.getMethod() + " " + request.getPath() + query;
|
||||
return "HTTP " + request.getMethod() + " \"" + request.getPath() + query + "\"";
|
||||
}
|
||||
|
||||
private void logResponse(ServerHttpResponse response) {
|
||||
if (logger.isDebugEnabled() || logger.isTraceEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
HttpStatus status = response.getStatusCode();
|
||||
String message = "Completed " + (status != null ? status : "200 OK");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user