Custom appender is being ignored

Java 11 and logback-classic-1.2.11 here. I'm trying to write my own custom appender and am following this Baeldung article <https://www.baeldung.com/custom-logback-appender> to test it out. My *src/main/java/myapp/logging/CatAppender* appender (on the runtime classpath): public class CatAppender extends AppenderBase<ILoggingEvent> { @Override protected void append(ILoggingEvent eventObject) { System.out.println("meow"); } } My *src/main/resources/logback.xml*: <?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <appender name="cat" class="myapp.logging.CatAppender"/> <root level="info"> <appender-ref ref="cat" /> </root> </configuration> In my *build.gradle* I specify to use logback and Lombok: plugins { id "io.freefair.lombok" version '6.4.0' } dependencies { implementation ( 'ch.qos.logback:logback-classic:1.2.11' ,'org.projectlombok:lombok:1.18.16' ) } And then in my Java code I use Lombok to inject an SLF4J logger like so: @Slf4j public class SomethingDoer { public void doSomething() { log.info("this should invoke the CatAppender..."); } } But when *SomethingDoer#doSomething()* runs, I don't see a meow printed to my STDOUT console. Have I wired anything up incorrectly here?

Hello Zac, AppenderBase will not invoke the append() method less the appender has the started flag set to true. -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 7/25/2022 6:38 PM, Zac Harvey wrote:
Java 11 and logback-classic-1.2.11 here. I'm trying to write my own custom appender and am following this Baeldung article <https://www.baeldung.com/custom-logback-appender> to test it out.
My *src/main/java/myapp/logging/CatAppender* appender (on the runtime classpath):
public class CatAppender extends AppenderBase<ILoggingEvent> { @Override protected void append(ILoggingEvent eventObject) { System.out.println("meow"); } }
My *src/main/resources/logback.xml*:
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true">
<appender name="cat" class="myapp.logging.CatAppender"/>
<root level="info"> <appender-ref ref="cat" /> </root>
</configuration>
In my *build.gradle* I specify to use logback and Lombok:
plugins { id "io.freefair.lombok" version '6.4.0' }
dependencies { implementation ( 'ch.qos.logback:logback-classic:1.2.11' ,'org.projectlombok:lombok:1.18.16' ) }
And then in my Java code I use Lombok to inject an SLF4J logger like so:
@Slf4j public class SomethingDoer {
public void doSomething() { log.info <http://log.info>("this should invoke the CatAppender..."); }
}
But when *SomethingDoer#doSomething()* runs, I don't see a meow printed to my STDOUT console. Have I wired anything up incorrectly here?

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! Best, Zac On Mon, Jul 25, 2022 at 2:14 PM Ceki Gülcü <ceki@qos.ch> wrote:
Hello Zac,
AppenderBase will not invoke the append() method less the appender has the started flag set to true.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch
On 7/25/2022 6:38 PM, Zac Harvey wrote:
Java 11 and logback-classic-1.2.11 here. I'm trying to write my own custom appender and am following this Baeldung article <https://www.baeldung.com/custom-logback-appender> to test it out.
My *src/main/java/myapp/logging/CatAppender* appender (on the runtime classpath):
public class CatAppender extends AppenderBase<ILoggingEvent> { @Override protected void append(ILoggingEvent eventObject) { System.out.println("meow"); } }
My *src/main/resources/logback.xml*:
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true">
<appender name="cat" class="myapp.logging.CatAppender"/>
<root level="info"> <appender-ref ref="cat" /> </root>
</configuration>
In my *build.gradle* I specify to use logback and Lombok:
plugins { id "io.freefair.lombok" version '6.4.0' }
dependencies { implementation ( 'ch.qos.logback:logback-classic:1.2.11' ,'org.projectlombok:lombok:1.18.16' ) }
And then in my Java code I use Lombok to inject an SLF4J logger like so:
@Slf4j public class SomethingDoer {
public void doSomething() { log.info <http://log.info>("this should invoke the CatAppender..."); }
}
But when *SomethingDoer#doSomething()* runs, I don't see a meow printed to my STDOUT console. Have I wired anything up incorrectly here?
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Works on my machine: https://github.com/yihtserns/test-logback-appender-custom When running the Main class in IDE: ```17:06:45: Executing task ':Main.main()'...
Task :generateEffectiveLombokConfig Task :compileJava Task :processResources Task :classes
Task :Main.main() 17:06:48,383 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 17:06:48,384 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/workspace/projects/test-logback-appender-custom/build/resources/main/logback.xml] 17:06:48,464 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.github.yihtserns.test.logback.appender.custom.CatAppender] 17:06:48,466 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [cat] 17:06:48,466 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO 17:06:48,466 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [cat] to Logger[ROOT] 17:06:48,467 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 17:06:48,468 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@61e4705b - Registering current configuration as safe fallback point Meow: Hello```
On Tuesday, 26 July 2022 at 02:27:51 GMT+8, Zac Harvey <bitbythecron@gmail.com> wrote: 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! Best,Zac On Mon, Jul 25, 2022 at 2:14 PM Ceki Gülcü <ceki@qos.ch> wrote: Hello Zac, AppenderBase will not invoke the append() method less the appender has the started flag set to true. -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 7/25/2022 6:38 PM, Zac Harvey wrote:
Java 11 and logback-classic-1.2.11 here. I'm trying to write my own custom appender and am following this Baeldung article <https://www.baeldung.com/custom-logback-appender> to test it out.
My *src/main/java/myapp/logging/CatAppender* appender (on the runtime classpath):
public class CatAppender extends AppenderBase<ILoggingEvent> { @Override protected void append(ILoggingEvent eventObject) { System.out.println("meow"); } }
My *src/main/resources/logback.xml*:
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true">
<appender name="cat" class="myapp.logging.CatAppender"/>
<root level="info"> <appender-ref ref="cat" /> </root>
</configuration>
In my *build.gradle* I specify to use logback and Lombok:
plugins { id "io.freefair.lombok" version '6.4.0' }
dependencies { implementation ( 'ch.qos.logback:logback-classic:1.2.11' ,'org.projectlombok:lombok:1.18.16' ) }
And then in my Java code I use Lombok to inject an SLF4J logger like so:
@Slf4j public class SomethingDoer {
public void doSomething() { log.info <http://log.info>("this should invoke the CatAppender..."); }
}
But when *SomethingDoer#doSomething()* runs, I don't see a meow printed to my STDOUT console. Have I wired anything up incorrectly here?
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

The start() method is akin to a constructor check. The start method should check whether all required parameters have been passed during configuration. If required parameters are missing, the appender should refuse to start and warn the user. The stop() method should release resources if any. -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 7/25/2022 8:27 PM, Zac Harvey wrote:
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!
Best, Zac
On Mon, Jul 25, 2022 at 2:14 PM Ceki Gülcü <ceki@qos.ch <mailto:ceki@qos.ch>> wrote:
Hello Zac,
AppenderBase will not invoke the append() method less the appender has the started flag set to true.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch <https://github.com/sponsors/qos-ch>
On 7/25/2022 6:38 PM, Zac Harvey wrote: > Java 11 and logback-classic-1.2.11 here. I'm trying to write my own > custom appender and am following this Baeldung article > <https://www.baeldung.com/custom-logback-appender <https://www.baeldung.com/custom-logback-appender>> to test it out. > > My *src/main/java/myapp/logging/CatAppender* appender (on the runtime > classpath): > > public class CatAppender extends AppenderBase<ILoggingEvent> { > @Override > protected void append(ILoggingEvent eventObject) { > System.out.println("meow"); > } > } > > My *src/main/resources/logback.xml*: > > <?xml version="1.0" encoding="UTF-8"?> > <configuration debug="true"> > > <appender name="cat" class="myapp.logging.CatAppender"/> > > <root level="info"> > <appender-ref ref="cat" /> > </root> > > </configuration> > > In my *build.gradle* I specify to use logback and Lombok: > > plugins { > id "io.freefair.lombok" version '6.4.0' > } > > dependencies { > implementation ( > 'ch.qos.logback:logback-classic:1.2.11' > ,'org.projectlombok:lombok:1.18.16' > ) > } > > And then in my Java code I use Lombok to inject an SLF4J logger like so: > > @Slf4j > public class SomethingDoer { > > public void doSomething() { > log.info <http://log.info> <http://log.info <http://log.info>>("this should invoke the CatAppender..."); > } > > } > > But when *SomethingDoer#doSomething()* runs, I don't see a meow printed > to my STDOUT console. Have I wired anything up incorrectly here? > _______________________________________________ logback-user mailing list logback-user@qos.ch <mailto:logback-user@qos.ch> http://mailman.qos.ch/mailman/listinfo/logback-user <http://mailman.qos.ch/mailman/listinfo/logback-user>
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
-- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch

Thanks again! If you don't mind, one *final* follow-up question regarding stop(): Do I need to wire my CatAppender#stop() calls up to any lifecycle hooks/calls called by logback/SLF4J itself, or is the idea that the *application* can stop an appender programmatically if the application desires to stop using it (stop logging) at any point? In my case, I can't think of a reason to expose the AppenderBase#stop() from the outside world (application) and allow the app to stop logging/appending. But should I override an AppenderBase method anyways, and call stop() from inside of it, and logback/SLF4J will call that overridden method at shutdown? Or is it safe in my case to just *not* call stop() at all, from anywhere inside the CatAppender? Thanks again so much! On Tue, Jul 26, 2022 at 5:37 AM Ceki Gülcü <ceki@qos.ch> wrote:
The start() method is akin to a constructor check.
The start method should check whether all required parameters have been passed during configuration. If required parameters are missing, the appender should refuse to start and warn the user.
The stop() method should release resources if any.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch
On 7/25/2022 8:27 PM, Zac Harvey wrote:
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!
Best, Zac
On Mon, Jul 25, 2022 at 2:14 PM Ceki Gülcü <ceki@qos.ch <mailto:ceki@qos.ch>> wrote:
Hello Zac,
AppenderBase will not invoke the append() method less the appender has the started flag set to true.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch < https://github.com/sponsors/qos-ch>
On 7/25/2022 6:38 PM, Zac Harvey wrote: > Java 11 and logback-classic-1.2.11 here. I'm trying to write my own > custom appender and am following this Baeldung article > <https://www.baeldung.com/custom-logback-appender <https://www.baeldung.com/custom-logback-appender>> to test it out. > > My *src/main/java/myapp/logging/CatAppender* appender (on the runtime > classpath): > > public class CatAppender extends AppenderBase<ILoggingEvent> { > @Override > protected void append(ILoggingEvent eventObject) { > System.out.println("meow"); > } > } > > My *src/main/resources/logback.xml*: > > <?xml version="1.0" encoding="UTF-8"?> > <configuration debug="true"> > > <appender name="cat" class="myapp.logging.CatAppender"/> > > <root level="info"> > <appender-ref ref="cat" /> > </root> > > </configuration> > > In my *build.gradle* I specify to use logback and Lombok: > > plugins { > id "io.freefair.lombok" version '6.4.0' > } > > dependencies { > implementation ( > 'ch.qos.logback:logback-classic:1.2.11' > ,'org.projectlombok:lombok:1.18.16' > ) > } > > And then in my Java code I use Lombok to inject an SLF4J logger like so: > > @Slf4j > public class SomethingDoer { > > public void doSomething() { > log.info <http://log.info> <http://log.info <http://log.info>>("this should invoke the CatAppender..."); > } > > } > > But when *SomethingDoer#doSomething()* runs, I don't see a meow printed > to my STDOUT console. Have I wired anything up incorrectly here? > _______________________________________________ logback-user mailing list logback-user@qos.ch <mailto:logback-user@qos.ch> http://mailman.qos.ch/mailman/listinfo/logback-user <http://mailman.qos.ch/mailman/listinfo/logback-user>
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch _______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Did you read my reply[1]? You shouldn't need to explicitly call `start()` nor `stop()` on your Appender implementation. Likely something is wrong with your project setup - you can start investigating by trying to run my working project, and comparing it with yours to understand why yours didn't work. [1] http://mailman.qos.ch/pipermail/logback-user/2022-July/005215.html On Tuesday, 26 July 2022 at 20:22:07 GMT+8, Zac Harvey <bitbythecron@gmail.com> wrote: Thanks again! If you don't mind, one final follow-up question regarding stop(): Do I need to wire my CatAppender#stop() calls up to any lifecycle hooks/calls called by logback/SLF4J itself, or is the idea that the application can stop an appender programmatically if the application desires to stop using it (stop logging) at any point? In my case, I can't think of a reason to expose the AppenderBase#stop() from the outside world (application) and allow the app to stop logging/appending. But should I override an AppenderBase method anyways, and call stop() from inside of it, and logback/SLF4J will call that overridden method at shutdown? Or is it safe in my case to just not call stop() at all, from anywhere inside the CatAppender? Thanks again so much! On Tue, Jul 26, 2022 at 5:37 AM Ceki Gülcü <ceki@qos.ch> wrote: The start() method is akin to a constructor check. The start method should check whether all required parameters have been passed during configuration. If required parameters are missing, the appender should refuse to start and warn the user. The stop() method should release resources if any. -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 7/25/2022 8:27 PM, Zac Harvey wrote:
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!
Best, Zac
On Mon, Jul 25, 2022 at 2:14 PM Ceki Gülcü <ceki@qos.ch <mailto:ceki@qos.ch>> wrote:
Hello Zac,
AppenderBase will not invoke the append() method less the appender has the started flag set to true.
-- Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch <https://github.com/sponsors/qos-ch>
On 7/25/2022 6:38 PM, Zac Harvey wrote: > Java 11 and logback-classic-1.2.11 here. I'm trying to write my own > custom appender and am following this Baeldung article > <https://www.baeldung.com/custom-logback-appender <https://www.baeldung.com/custom-logback-appender>> to test it out. > > My *src/main/java/myapp/logging/CatAppender* appender (on the runtime > classpath): > > public class CatAppender extends AppenderBase<ILoggingEvent> { > @Override > protected void append(ILoggingEvent eventObject) { > System.out.println("meow"); > } > } > > My *src/main/resources/logback.xml*: > > <?xml version="1.0" encoding="UTF-8"?> > <configuration debug="true"> > > <appender name="cat" class="myapp.logging.CatAppender"/> > > <root level="info"> > <appender-ref ref="cat" /> > </root> > > </configuration> > > In my *build.gradle* I specify to use logback and Lombok: > > plugins { > id "io.freefair.lombok" version '6.4.0' > } > > dependencies { > implementation ( > 'ch.qos.logback:logback-classic:1.2.11' > ,'org.projectlombok:lombok:1.18.16' > ) > } > > And then in my Java code I use Lombok to inject an SLF4J logger like so: > > @Slf4j > public class SomethingDoer { > > public void doSomething() { > log.info <http://log.info> <http://log.info <http://log.info>>("this should invoke the CatAppender..."); > } > > } > > But when *SomethingDoer#doSomething()* runs, I don't see a meow printed > to my STDOUT console. Have I wired anything up incorrectly here? > _______________________________________________ logback-user mailing list logback-user@qos.ch <mailto:logback-user@qos.ch> http://mailman.qos.ch/mailman/listinfo/logback-user <http://mailman.qos.ch/mailman/listinfo/logback-user>
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
-- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch _______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user _______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (3)
-
Ceki Gülcü
-
YihTsern
-
Zac Harvey