Custom Appender for Logback #12478
-
Using Play Framework 3.0.1
I think that is the most important part of the Error. What I did is created logback.appenders.TestAppender in the app folder. The TestAppender code is pretty simple: package logback.appenders;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
public class TestAppender extends AppenderBase<ILoggingEvent> {
@Override
protected void append(ILoggingEvent event) {
if (!isStarted()) {
return;
}
System.out.println( event.getFormattedMessage() );
}
} And in the logback.xml config I added inside configuration tag: <import class="logback.appenders.TestAppender"/>
<appender name="TEST" class="TestAppender">
</appender>
<root level="INFO">
<appender-ref ref="TEST"/>
</root> If i'm not wrong everything in the app directory should be in the classpath as it gets compiled in the target/scala-2.13 directory and I've confirm that I can see the TestAppender.class inside it. What am I missing to make this work ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi, @MihaiBeigar! |
Beta Was this translation helpful? Give feedback.
Hi, @MihaiBeigar!
Did you catch this error in Dev or Prod mode? It's can be related to specific Play classloaders that is used in Dev-mode.
To check my assumption, you can move your appender into separated library and use this library as a dependency like Logback itself.