[logback-user] Multiple layouts for a single appender

Y M ym119162 at hotmail.com
Wed May 16 15:27:16 CEST 2012

My situation is this: on certain specific and frequent log statements, I need the stacktrace to identify the method that needs to be investigated. However, the whole stacktrace is too long and unnecessary in this case (it is generating too much logging and garbage), but in every other, it is useful. I'd like to change the layout for this situation, and use %throwable{5}, for example.
So, I found nothing on the manual similar to this, and nothing searching around, maybe I'll need a custom class. If so, how could I do it? Multiple filtered appenders writing to the same file seems too much overhead and troublesome; I think the best approach would be a custom encoder, and do the selection inside 'doEncode', based on some event parameter, probably a specific marker. I'm just analyzing the possibilities, no coding yet, so I'm not aware of any shortcomings or limitations.
Given the case, is there any API class I'm missing to do this? Should I take the custom code path?

More information about the Logback-user mailing list