I think this is a bug in ThrowableProxy. Could you please create a jira issue for this? Thank you.

On 16.07.2012 23:24, Abraham Lin wrote:
Hi Ceki,

Thanks for the response. Here's a trivial example:

   public class Main {
     public static void main( String[] args ) {
       org.slf4j.Logger logger = org.slf4j.LoggerFactory
           .getLogger( Main.class );
       Exception e1 = new CustomException( );
       e1.printStackTrace( System.out );
logger.info <http://logger.info>( "", e1 );
       System.out.println( );
       Exception e2 = new CustomException( "Test message" );
       e2.printStackTrace( System.out );
logger.info <http://logger.info>( "", e2 );
     }
     static class CustomException extends Exception {
       CustomException( ) {}
       CustomException( String message ) { super( message ); }
       @Override
       public String toString( ) {
         return super.toString( ) + " (from toString)";
       }
     }
   }

Running the above yields this output:

   com.example.logback.Main$CustomException (from toString)
     at com.example.logback.Main.main(Main.java:7)
   17:19:50.445 [main] INFO  com.example.logback.Main -
   com.example.logback.Main$CustomException: null
     at com.example.logback.Main.main(Main.java:7) ~[classes/:na]
   com.example.logback.Main$CustomException: Test message (from toString)
     at com.example.logback.Main.main(Main.java:13)
   17:19:50.451 [main] INFO  com.example.logback.Main -
   com.example.logback.Main$CustomException: Test message
     at com.example.logback.Main.main(Main.java:13) ~[classes/:na]

What do you think?

-Abraham


On Mon, Jul 16, 2012 at 5:02 PM, ceki <c...@qos.ch <mailto:c...@qos.ch>>
wrote:

    Hi Abraham,

    Can you provide an example of the difference?
    --
    Ceki
    http://tinyurl.com/proLogback


    On 16.07.2012 22:32, Abraham Lin wrote:

        Hi,

        In comparing the outputs of Throwable#printStackTrace and logback, I
        found an inconsistency in how the Throwable instances are
        printed. While
        the former delegates to the Throwable instance's #toString
        method, the
        latter (partially) re-implements the default implementation in
        Throwable, which means that data contained in the #toString
        methods of
        Throwable subclasses is discarded. While this is easy to work
        around in
        my own code, there is still a problem when working with third-party
        libraries.

        Is there a configuration option that would allow me to specify
        my own
        IThrowableProxy implementation? (I couldn't find any pages
        describing
        the extension points and how to activate them.) Or would it be more
        appropriate to modify the ThrowableProxyUtil class so that it
        behaves
        similarly to #printStackTrace? Any ideas would be greatly
        appreciated.

        Thanks in advance!

        -Abraham





--
Ceki
http://tinyurl.com/proLogback


_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to