org.apache.logging.log4j.core.appender.rewrite.RewriteAppender Java Examples
The following examples show how to use
org.apache.logging.log4j.core.appender.rewrite.RewriteAppender.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeobfuscatingRewritePolicy.java From VanillaFix with MIT License | 6 votes |
/** Modifies the log4j config to add the policy **/ public static void install() { Logger rootLogger = (Logger) LogManager.getRootLogger(); LoggerConfig loggerConfig = rootLogger.get(); // Remove appender refs from config List<AppenderRef> appenderRefs = new ArrayList<>(loggerConfig.getAppenderRefs()); for (AppenderRef appenderRef : appenderRefs) { loggerConfig.removeAppender(appenderRef.getRef()); } // Create the RewriteAppender, which wraps the appenders RewriteAppender rewriteAppender = RewriteAppender.createAppender( "VanillaFixDeobfuscatingAppender", "true", appenderRefs.toArray(new AppenderRef[0]), rootLogger.getContext().getConfiguration(), new DeobfuscatingRewritePolicy(), null ); rewriteAppender.start(); // Add the new appender loggerConfig.addAppender(rewriteAppender, null, null); }
Example #2
Source File: LoggerLoader.java From syncope with Apache License 2.0 | 6 votes |
public static void addAppenderToContext( final LoggerContext ctx, final AuditAppender auditAppender, final LoggerConfig eventLogConf) { Appender targetAppender = ctx.getConfiguration().getAppender(auditAppender.getTargetAppenderName()); if (targetAppender == null) { targetAppender = auditAppender.getTargetAppender(); } targetAppender.start(); ctx.getConfiguration().addAppender(targetAppender); Optional<RewriteAppender> rewriteAppender = auditAppender.getRewriteAppender(); if (rewriteAppender.isPresent()) { rewriteAppender.get().start(); eventLogConf.addAppender(rewriteAppender.get(), Level.DEBUG, null); } else { eventLogConf.addAppender(targetAppender, Level.DEBUG, null); } }
Example #3
Source File: RewriteAppenderBuilder.java From logging-log4j2 with Apache License 2.0 | 6 votes |
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)); }
Example #4
Source File: DefaultRewriteAuditAppender.java From syncope with Apache License 2.0 | 5 votes |
@Override public void init(final String domain) { super.init(domain); rewriteAppender = RewriteAppender.createAppender( getTargetAppenderName() + "_rewrite", "true", new AppenderRef[] { AppenderRef.createAppenderRef(getTargetAppenderName(), Level.DEBUG, null) }, ((LoggerContext) LogManager.getContext(false)).getConfiguration(), getRewritePolicy(), null); }
Example #5
Source File: DefaultRewriteAuditAppender.java From syncope with Apache License 2.0 | 4 votes |
@Override public Optional<RewriteAppender> getRewriteAppender() { return Optional.of(rewriteAppender); }
Example #6
Source File: AuditAppender.java From syncope with Apache License 2.0 | 4 votes |
default Optional<RewriteAppender> getRewriteAppender() { return Optional.empty(); }