Hello,
I want to use Log4J2 in my Eclipse 3.7.2 RCP application.
Log4J2 has a problem finding my appender „AppenderTest“. Without running the
code in RCP my code worked.
2020-08-14 13:06:29,431 main DEBUG Took 0,221691 seconds to load 0 plugins from
package com.my.rcp.application.logging
2020-08-14 13:06:29,440 main ERROR Unable to locate plugin type for AppenderTest
It obviously has problems finding the „plugin“.
In the users guide they explained that the PluginManager locates plugins by
looking in five places. The second entry is:
(OSGi only) Serialized plugin listing files in each active OSGi bundle.
Can someone tell me how it is realized? I cannot find any detailed information.
Regards,
Florian
This is my code:
Method in Activator of Eclipse-PlugIn:
private void configureLog4J2() {
ConfigurationBuilder<BuiltConfiguration> builder =
ConfigurationBuilderFactory.newConfigurationBuilder();
builder.setStatusLevel(Level.ALL);
// Add GLP appender
builder.setPackages("com.my.rcp.application.logging");
AppenderComponentBuilder appenderBuilder =
builder.newAppender("Appender", "AppenderTest");
builder.add(appenderBuilder);
// Add GLP logger
builder.add(builder.newLogger("com.my.rcp.application.logger.test").add(builder.newAppenderRef("Appender")).addAttribute("additivity",
false));
// Initialize
Configurator.initialize(builder.build());
}
Appender class:
@Plugin(name = "AppenderTest", category = "Core", elementType = "appender",
printObject = true)
public class AppenderTest extends AbstractAppender {
private static AppenderTest instance;
protected AppenderTest (String name, Filter filter, Layout<? extends
Serializable> layout) {
super(name, filter, layout, false, Property.EMPTY_ARRAY);
}
@Override
public void append(LogEvent logEvent) {
// do something
}
@PluginFactory
public static AppenderGlp createAppender(@PluginAttribute("name") String
name, @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filters") Filter filter) {
if(layout == null)
layout = PatternLayout.createDefaultLayout();
instance = new AppenderGlp(name, filter, layout);
return instance;
}
}