<div dir="ltr"><div>Thank you Ceki! I called start() in the CatAppender constructor and everything is now working. Are there recommended practices as to when (and from where) to call start() and stop()? Thanks again so much!</div><div><br></div><div>Best,</div><div>Zac<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 25, 2022 at 2:14 PM Ceki Gülcü <<a href="mailto:ceki@qos.ch">ceki@qos.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Zac,<br>
<br>
AppenderBase will not invoke the append() method less the appender has<br>
the started flag set to true.<br>
<br>
<br>
-- <br>
Ceki Gülcü<br>
<br>
Sponsoring SLF4J/logback/reload4j at <a href="https://github.com/sponsors/qos-ch" rel="noreferrer" target="_blank">https://github.com/sponsors/qos-ch</a><br>
<br>
On 7/25/2022 6:38 PM, Zac Harvey wrote:<br>
> Java 11 and logback-classic-1.2.11 here. I'm trying to write my own<br>
> custom appender and am following this Baeldung article<br>
> <<a href="https://www.baeldung.com/custom-logback-appender" rel="noreferrer" target="_blank">https://www.baeldung.com/custom-logback-appender</a>> to test it out.<br>
> <br>
> My *src/main/java/myapp/logging/CatAppender* appender (on the runtime<br>
> classpath):<br>
> <br>
> public class CatAppender extends AppenderBase<ILoggingEvent> {<br>
> @Override<br>
> protected void append(ILoggingEvent eventObject) {<br>
> System.out.println("meow");<br>
> }<br>
> }<br>
> <br>
> My *src/main/resources/logback.xml*:<br>
> <br>
> <?xml version="1.0" encoding="UTF-8"?><br>
> <configuration debug="true"><br>
> <br>
> <appender name="cat" class="myapp.logging.CatAppender"/><br>
> <br>
> <root level="info"><br>
> <appender-ref ref="cat" /><br>
> </root><br>
> <br>
> </configuration><br>
> <br>
> In my *build.gradle* I specify to use logback and Lombok:<br>
> <br>
> plugins {<br>
> id "io.freefair.lombok" version '6.4.0'<br>
> }<br>
> <br>
> dependencies {<br>
> implementation (<br>
> 'ch.qos.logback:logback-classic:1.2.11'<br>
> ,'org.projectlombok:lombok:1.18.16'<br>
> )<br>
> }<br>
> <br>
> And then in my Java code I use Lombok to inject an SLF4J logger like so:<br>
> <br>
> @Slf4j<br>
> public class SomethingDoer {<br>
> <br>
> public void doSomething() {<br>
> <a href="http://log.info" rel="noreferrer" target="_blank">log.info</a> <<a href="http://log.info" rel="noreferrer" target="_blank">http://log.info</a>>("this should invoke the CatAppender...");<br>
> }<br>
> <br>
> }<br>
> <br>
> But when *SomethingDoer#doSomething()* runs, I don't see a meow printed<br>
> to my STDOUT console. Have I wired anything up incorrectly here?<br>
> <br>
_______________________________________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/listinfo/logback-user</a></blockquote></div>