I am relatively new to Logback. I have figured out how to create a custom layout.
But sometimes based on information in the event I would like the ability to use a pattern in the doLayout method. Is there code for converting an Event using an Pattern broken out into a separate reuseable classes. Something like this:
public class MyCustomLayout extends LayoutBase<ILoggingEvent> {
String doLayout(Event e) {
[Based on some condition]
Pattern p = "%mdc";
String convertedPatternToString = p.process(e);
....
}
}
Is there a Pattern object that will do that in logback?
I realize I could do this with two separate appenders (one with PatternLayoutEncoder and one with MyCustomLayout.) But I really have needs to have it one layout class.
Thanks.
Aucun commentaire:
Enregistrer un commentaire