5

I have some specific problem with logback. We've migrated from log4j to logback and all seems to be alright, but we have an exception class MultiCauseException. As you guessed - it can have more than one cause exception, so the problem is: I can't manually format stacktrace to see all causes.

Why it was working. Log4j used method printStackTrace() and you can override it in MultiCauseException and the problem is gone. But logback uses his own methods and I don't know how to replace them.

I want to log all causes correctly.

In class I have

MultiCauseException nextInChain; // my cause
Throwable inner; 
        // the real exception (inner.getCause() can be != null - must be logged)

And

 @Override
    public Throwable getCause() {
        return nextInChain;
    }
3
  • Which version of Logback are you using?
    – fglez
    Oct 17, 2012 at 9:55
  • 1.0.7 - the latest at the moment
    – Edd
    Oct 22, 2012 at 6:21
  • I decided to make stack complitely "plane" (Now "caused by" don't really means the cause). But question is not really closed... Yes, my English is terrible, sorry about that:)
    – Edd
    Oct 22, 2012 at 6:26

1 Answer 1

1

Logback has something called Layouts that is suppoesed to format events to strings . But I still believe you should be able to configure it with PatternLayout

1
  • Thanks. But in this case I need to modify config file to replace standart layout to my own. And when I add my exception in other classes, I need to modify appenders again. Thats a suggestion, but it'll be better if I can modify only MultiCauseException class (or add something, but once)
    – Edd
    Oct 15, 2012 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.