[
https://issues.apache.org/jira/browse/RATIS-1946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17791774#comment-17791774
]
Attila Doroszlai commented on RATIS-1946:
-----------------------------------------
[~szetszwo], I think SLF4J's adapter for Log4j/Reload4j handles that,
extracting the {{Throwable}} from last position of the arguments array, if
present:
https://github.com/qos-ch/slf4j/blob/e9ee55cca93c2bf26f14482a9bdf961c750d2a56/slf4j-reload4j/src/main/java/org/slf4j/impl/Reload4jLoggerAdapter.java#L441-L446
https://github.com/qos-ch/slf4j/blob/e9ee55cca93c2bf26f14482a9bdf961c750d2a56/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java#L155-L162
https://github.com/qos-ch/slf4j/blob/e9ee55cca93c2bf26f14482a9bdf961c750d2a56/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java#L392-L411
> slf4j: Exception may not be printed.
> ------------------------------------
>
> Key: RATIS-1946
> URL: https://issues.apache.org/jira/browse/RATIS-1946
> Project: Ratis
> Issue Type: Improvement
> Reporter: Tsz-wo Sze
> Assignee: Tsz-wo Sze
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The "{}" message format syntax does not work for exception.
> {code}
> //PeerProxyMap.java
> } catch (IOException e) {
> LOG.warn("{}: Failed to close proxy for peer {}, proxy class: {}",
> name, pp, proxy.getClass(), e);
> }
> {code}
> As an example, the exception e and its stack trace will not be printed in the
> code above since it is calling
> {code}
> //org.slf4j.Logger
> void warn(String var1, Object... var2);
> {code}
> with one "{}" less. There are three "{}" but four objects (including e).
> The expectation is to call
> {code}
> void warn(String var1, Object var2, Object var3, Object var4, Throwable
> var5);
> {code}
> but such method does not exist.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)