I have an Async appender that works only when I set the level=debug. For "error" level it does not log anything.
<Configuration packages="com.custom.appender">
<Appenders>
<CustomLogger name="customLogger"/>
<Async name="customAsync" bufferSize="2" includeLocation="flase">
<AppenderRef ref="customLogger"/>
</Async>
</Appenders>
<Loggers>
<logger name="com.mypackage" level="error">
<AppenderRef ref="customAsync"/>
</logger>
</Loggers>
</Configuration>
I am not sure what I am missing in this configuration. This is the custom appender that I am trying to use
package com.custom.appender
@Plugin(name = "CustomLogger", category = "Core", elementType = "appender", printObject = true)
public class CustomLogger extends AbstractAppender {
private static volatile CustomLogger instance;
public CustomLogger(final String name, final Filter filter,
final Layout<? extends Serializable> layout) {
super(name, filter, layout);
}
@PluginFactory
public static CustomLogger createAppender(
@PluginAttribute("name") String name,
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
@PluginElement("Layout") Layout layout,
@PluginElement("Filters") Filter filter) {
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
instance = new CustomLogger(name, filter, layout);
return instance;
}
public static CustomLogger getInstance() {
return instance;
}
@Override
public void append(LogEvent event) {
//Log the event to mongoDB
}
}
Try the following