Search in sources :

Example 1 with RewritePolicyWrapper

use of org.apache.log4j.bridge.RewritePolicyWrapper in project logging-log4j2 by apache.

the class RewriteAppenderBuilder method createAppender.

private <T extends Log4j1Configuration> Appender createAppender(String name, String level, String[] appenderRefs, RewritePolicy policy, Filter filter, T configuration) {
    org.apache.logging.log4j.Level logLevel = OptionConverter.convertLevel(level, org.apache.logging.log4j.Level.TRACE);
    AppenderRef[] refs = new AppenderRef[appenderRefs.length];
    int index = 0;
    for (String appenderRef : appenderRefs) {
        refs[index++] = AppenderRef.createAppenderRef(appenderRef, logLevel, null);
    }
    org.apache.logging.log4j.core.Filter rewriteFilter = buildFilters(level, filter);
    org.apache.logging.log4j.core.appender.rewrite.RewritePolicy rewritePolicy;
    if (policy instanceof RewritePolicyWrapper) {
        rewritePolicy = ((RewritePolicyWrapper) policy).getPolicy();
    } else {
        rewritePolicy = new RewritePolicyAdapter(policy);
    }
    return new AppenderWrapper(RewriteAppender.createAppender(name, true, refs, configuration, rewritePolicy, rewriteFilter));
}
Also used : RewritePolicyAdapter(org.apache.log4j.bridge.RewritePolicyAdapter) AppenderWrapper(org.apache.log4j.bridge.AppenderWrapper) RewritePolicyWrapper(org.apache.log4j.bridge.RewritePolicyWrapper) AppenderRef(org.apache.logging.log4j.core.config.AppenderRef)

Aggregations

AppenderWrapper (org.apache.log4j.bridge.AppenderWrapper)1 RewritePolicyAdapter (org.apache.log4j.bridge.RewritePolicyAdapter)1 RewritePolicyWrapper (org.apache.log4j.bridge.RewritePolicyWrapper)1 AppenderRef (org.apache.logging.log4j.core.config.AppenderRef)1