[
http://jira.qos.ch/browse/LBCLASSIC-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11088#action_11088
]
Thorbjoern Ravn Andersen commented on LBCLASSIC-107:
----------------------------------------------------
I did some work on this with the logger agent in slf4j where any object is a
candidate for a toString call (which may have devastating effects).
I don't think the exception should propagate to the calling program. Changing
loglevels should not influence program execution as such.
> thrown from toString exception swallowed
> ----------------------------------------
>
> Key: LBCLASSIC-107
> URL: http://jira.qos.ch/browse/LBCLASSIC-107
> Project: logback-classic
> Issue Type: Bug
> Affects Versions: 0.9.15
> Environment: java version "1.6.0_12"
> Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
> Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
> slf4j-api:1.5.6
> Reporter: Anton Lebedevich
> Assignee: Logback dev list
>
> package loggerbug;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> public class Loggerbug
> {
> private static final Logger logger =
> LoggerFactory.getLogger(Loggerbug.class);
>
> static class ThrowsToString {
> @Override
> public String toString() {
> throw new RuntimeException("from toString");
> }
> }
>
> public static void main(String[] args)
> {
> ThrowsToString probe = new ThrowsToString();
> logger.info("probe is {}", probe);
> System.out.println("no exception");
> }
> }
> prints "no exception" with logback-classic, but with slf4j-simple output is:
> Exception in thread "main" java.lang.RuntimeException: from toString
> at loggerbug.Loggerbug$ThrowsToString.toString(Loggerbug.java:13)
> at java.lang.String.valueOf(String.java:2827)
> at java.lang.StringBuffer.append(StringBuffer.java:219)
> at
> org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:237)
> at
> org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:196)
> at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:138)
> at org.slf4j.impl.SimpleLogger.formatAndLog(SimpleLogger.java:222)
> at org.slf4j.impl.SimpleLogger.info(SimpleLogger.java:258)
> at loggerbug.Loggerbug.main(Loggerbug.java:20)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
logback-dev mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-dev