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

Reply via email to