|
|
|
@ -27,6 +27,7 @@ import javax.servlet.http.HttpSession; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.util.ContentCachingRequestWrapper; |
|
|
|
import org.springframework.web.util.ContentCachingRequestWrapper; |
|
|
|
|
|
|
|
import org.springframework.web.util.WebUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Base class for {@code Filter}s that perform logging operations before and after a request |
|
|
|
* Base class for {@code Filter}s that perform logging operations before and after a request |
|
|
|
@ -270,21 +271,23 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter |
|
|
|
msg.append(";user=").append(user); |
|
|
|
msg.append(";user=").append(user); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (isIncludePayload() && request instanceof ContentCachingRequestWrapper) { |
|
|
|
if (isIncludePayload()) { |
|
|
|
ContentCachingRequestWrapper wrapper = (ContentCachingRequestWrapper) request; |
|
|
|
ContentCachingRequestWrapper wrapper = |
|
|
|
byte[] buf = wrapper.getContentAsByteArray(); |
|
|
|
WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class); |
|
|
|
if (buf.length > 0) { |
|
|
|
if (wrapper != null) { |
|
|
|
int length = Math.min(buf.length, getMaxPayloadLength()); |
|
|
|
byte[] buf = wrapper.getContentAsByteArray(); |
|
|
|
String payload; |
|
|
|
if (buf.length > 0) { |
|
|
|
try { |
|
|
|
int length = Math.min(buf.length, getMaxPayloadLength()); |
|
|
|
payload = new String(buf, 0, length, wrapper.getCharacterEncoding()); |
|
|
|
String payload; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
payload = new String(buf, 0, length, wrapper.getCharacterEncoding()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (UnsupportedEncodingException ex) { |
|
|
|
|
|
|
|
payload = "[unknown]"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
msg.append(";payload=").append(payload); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (UnsupportedEncodingException e) { |
|
|
|
|
|
|
|
payload = "[unknown]"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
msg.append(";payload=").append(payload); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
msg.append(suffix); |
|
|
|
msg.append(suffix); |
|
|
|
return msg.toString(); |
|
|
|
return msg.toString(); |
|
|
|
|