I wrote a custom appender JTableAppender
which implements ILoggingEvent
. This appender has a public setter setModel(..)
to assign a table model to the appender, so I can manipulate the model in doAppend()
.
The JTableAppender is configurated in an xml file, where I named it TABLE:
<appender name="TABLE" class="blabla.jgwf.test.logger.JTableAppender">
<!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
To be able to use the setter from the outside, I tried to get the appender using
Logger logger = (Logger) LoggerFactory.getLogger("blabal");
JTableAppender<ILoggingEvent> appender = (JTableAppender<ILoggingEvent>)logger.getAppender("TABLE");
When I tried to set a model using
appender.setModel(...);
I got a NullPointerException for exactly this line. The getAppender() didn't work as I wish it would.