[jboss-jira] [JBoss JIRA] (JGRP-1757) Logging: exceptions are not logged correctly
Bela Ban (JIRA)
issues at jboss.org
Fri Dec 20 04:36:33 EST 2013
[ https://issues.jboss.org/browse/JGRP-1757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12932828#comment-12932828 ]
Bela Ban commented on JGRP-1757:
--------------------------------
The problem is that I used log.error/warn(String format, Throwable t) the wrong way:
Correct use:
{code:java}
catch(Throwable t) {
log.error("there was a problem", t);
}
{code}
Incorrect use:
{code:java}
catch(Throwable t) {
log.error("there was a problem: %s", t);
}
{code}
The format parameter %s is not needed.
If we call
{code:java}
log.error("%s: there was a problem", local_addr, t);
{code}
, then we'll use {{log.error(String format, Object ... args)}}, and t will be evaluated as an object and its toString() method will be called (no stack trace).
> Logging: exceptions are not logged correctly
> --------------------------------------------
>
> Key: JGRP-1757
> URL: https://issues.jboss.org/browse/JGRP-1757
> Project: JGroups
> Issue Type: Bug
> Reporter: Bela Ban
> Assignee: Bela Ban
> Priority: Minor
> Fix For: 3.4.2, 3.5
>
>
> When calling
> {code:java}
> log.error("failure: %s", new NullPointerException("booom"));
> {code}, the stack trace of the exception is not shown immediately following the error string:
> {noformat}
> 704 [ERROR] jgroups: failure: %s
> java.lang.NullPointerException: booom
> at org.jgroups.tests.bla4.main(bla4.java:14) [classes/:?]
> {noformat}
> Invoking {{toString()}} on the exception works, but in some cases, we want to be able to see the stack trace.
> Investigate how to show the stack trace on all (currently) 3 loggers (JDK, log4j and log4j2).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list