Unable to locate plugin type for Custom log4j2 Appender
Amanda Liu <[email protected]> Mon, 5 Aug 2024 06:23:40 -0700
| Newsgroups | gmane.comp.jakarta.log4j.user |
|---|---|
| Message-ID | <CAEycFyTurhnw6NCsZzHbYEo9sabEOOJp+bpLESeaFi-hbOwbuQ@mail.gmail.com> |
--0000000000007e5455061eef9661 Content-Type: text/plain; charset="UTF-8" Hi, I am using log4j2 to set up logging in my project. Currently, I use JsonTemplateLayout and console appender type, which works fine: (from my log4j.properties file:) > ... > appender.console.type = Console > appender.console.name = console > appender.console.target = SYSTEM_ERR > appender.console.layout.type = JsonTemplateLayout > ... However, I'd like to implement some custom formatting on top of the default JsonTemplateLayout. I read the docs <https://logging.apache.org/log4j/2.x/manual/extending.html> about extending log4j2 using a custom appender class, however when I run my program with these log4j.properties settings: rootLogger.appenderRef.stdout.ref = packageName.CustomAppender > appender.console.type = CustomAppender appender.console.name = CustomAppender appender.console.target = SYSTEM_ERR appender.console.layout.type = JsonTemplateLayout > log4j2.plugin.packages = packageName I get these errors: ERROR StatusConsoleListener Unable to locate plugin type for CustomAppender ERROR StatusConsoleListener Unable to locate plugin for CustomAppender Wondering if I'm missing some step of the set-up process for custom appenders? I thought that adding the appender class and modifying the log4j.properties file should be sufficient, as the plug-ins docs say "Serialized plugin listing files are generated by an annotation processor contained in the log4j-core artifact which will automatically scan your code for Log4j 2 plugins and output a metadata file in your processed classes. There is nothing extra that needs to be done to enable this; the Java compiler will automatically pick up the annotation processor on the class path unless you explicitly disable it" ( https://logging.apache.org/log4j/2.x/manual/plugins.html) Appreciate any help I could get, thank you! --0000000000007e5455061eef9661--