Feign logger and multipart/form-data content type
I am doing some tests with Feign logger and have observed that with Feign logging level set to FULL and package logging level set to DEBUG, this Feign API logs the body;
@Headers(value={"Content-Type: application/json", "X-Auth-Username: {authUsername}"})
but this API does not log the body;
@Headers(value={"Content-Type: multipart/form-data", "X-Auth-Username: {authUsername}"})
The reason is that code in feign.Logger class requires a charset to be associated with the content type before it will print it;
if (logLevel.ordinal() >= Level.FULL.ordinal()) {
String bodyText =
request.charset() != null ? new String(request.body(), request.charset()) : null;
and when the content type is "application/json", the request.charset() method is non-null, whereas when the content type is "multipart/form-data", the request.charset() method is null.
RFC 7578 does not allow a charset parameter for the multipart/form-data content type.
I can write a custom logger to work around this but is this an omission in Feign logging ? or is there a deliberate strategy behind it.
Yes, you will need your own logging implementation for this to work. Our included logger implementation is simple and works for the most basic of use cases. See our documentation on logging for information.