private Configuration createConfiguration(final String name, ConfigurationBuilder<BuiltConfiguration> builder) { builder.setConfigurationName(name); /* Only internal Log4J2 messages with level ERROR will be logged */ builder.setStatusLevel(Level.ERROR); /* Create appender that logs to System.out */ AppenderComponentBuilder appenderBuilder = builder.newAppender("STDOUT", "CONSOLE") .addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); /* Create pattern for log messages */ appenderBuilder.add(builder.newLayout("PatternLayout") .addAttribute("pattern", "[%d{HH:mm:ss}] (%c{1}) [%level] %msg%n%throwable")); /*timestamp logger name level log message & optional throwable */ builder.add(appenderBuilder); /* Create logger that uses STDOUT appender */ builder.add(builder.newLogger("JukeBot", JUKEBOT_LOG_LEVEL) .add(builder.newAppenderRef("STDOUT")) .addAttribute("additivity", false)); /* Create root logger--messages not from the above logger will all go through this one */ builder.add(builder.newRootLogger(LIB_LOG_LEVEL).add(builder.newAppenderRef("STDOUT"))); return builder.build(); }
protected Configuration buildConfiguration() { ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder(); builder.setConfigurationName(Log4j2RedactorTest.class.getName()); builder.setStatusLevel(Level.INFO); AppenderComponentBuilder appenderBuilder = builder.newAppender("Stderr", "CONSOLE") .addAttribute("target", ConsoleAppender.Target.SYSTEM_ERR); appenderBuilder.add(builder.newLayout("PatternLayout") .addAttribute("pattern", "%msg")); builder.add(appenderBuilder); AppenderComponentBuilder rewriteBuilder = builder.newAppender("Redactor", "Rewrite") .addComponent(builder.newComponent("RedactorPolicy", "RedactorPolicy") .addAttribute("rules", resourcePath + getPolicyFilename())) .addComponent(builder.newAppenderRef("Stderr")); builder.add(rewriteBuilder); builder.add(builder.newRootLogger(Level.INFO) .add(builder.newAppenderRef("Redactor"))); return builder.build(); }
@Test public void testBuildConfiguration() throws Exception { try { System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory .newConfigurationBuilder(); CustomConfigurationFactory.addTestFixtures("config name", builder); final Configuration configuration = builder.build(); try (LoggerContext ctx = Configurator.initialize(configuration)) { validate(configuration); } } finally { System.getProperties().remove(Constants.LOG4J_CONTEXT_SELECTOR); } }
@Test public void testBuilder() throws Exception { final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setStatusLevel(Level.ERROR); builder.setConfigurationName("BuilderTest"); builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL) .addAttribute("level", Level.DEBUG)); final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout"). addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable")); appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY, Filter.Result.NEUTRAL).addAttribute("marker", "FLOW")); builder.add(appenderBuilder); builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG). add(builder.newAppenderRef("Stdout")). addAttribute("additivity", false)); builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))); ctx = Configurator.initialize(builder.build()); final Configuration config = ctx.getConfiguration(); assertNotNull("No configuration", config); assertEquals("Unexpected Configuration", "BuilderTest", config.getName()); assertThat(config.getAppenders(), hasSize(equalTo(1))); }
private void addTestFixtures(final String name, final ConfigurationBuilder<BuiltConfiguration> builder) { builder.setConfigurationName(name); builder.setStatusLevel(Level.ERROR); builder.setShutdownTimeout(5000, TimeUnit.MILLISECONDS); builder.add(builder.newScriptFile("target/test-classes/scripts/filter.groovy").addIsWatched(true)); builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL) .addAttribute("level", Level.DEBUG)); final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout"). addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable")); appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY, Filter.Result.NEUTRAL).addAttribute("marker", "FLOW")); builder.add(appenderBuilder); builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG, true). add(builder.newAppenderRef("Stdout")). addAttribute("additivity", false)); builder.add(builder.newLogger("org.apache.logging.log4j.core"). add(builder.newAppenderRef("Stdout"))); builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))); builder.addProperty("MyKey", "MyValue"); builder.add(builder.newCustomLevel("Panic", 17)); builder.setPackages("foo,bar"); }
public static Configuration addTestFixtures(final String name, final ConfigurationBuilder<BuiltConfiguration> builder) { builder.setConfigurationName(name); builder.setStatusLevel(Level.ERROR); builder.add(builder.newScriptFile("target/test-classes/scripts/filter.groovy").addIsWatched(true)); builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL) .addAttribute("level", Level.DEBUG)); final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder. newLayout("PatternLayout"). addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable")); appenderBuilder.add(builder. newFilter("MarkerFilter", Filter.Result.DENY, Filter.Result.NEUTRAL). addAttribute("marker", "FLOW")); builder.add(appenderBuilder); builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG, true). add(builder.newAppenderRef("Stdout")). addAttribute("additivity", false)); builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))); builder.add(builder.newCustomLevel("Panic", 17)); return builder.build(); }
private ConfigurationBuilder<BuiltConfiguration> buildConfigurationBuilder(final String filePattern) { final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setConfigurationName("LOG4J2-1964 demo"); builder.setStatusLevel(Level.ERROR); // @formatter:off builder.add(builder.newAppender("consoleLog", "Console") .addAttribute("target", ConsoleAppender.Target.SYSTEM_ERR)); builder.add(builder.newAppender("fooAppender", "RollingFile") .addAttribute("fileName", "target/rolling-update-date/foo.log") .addAttribute("filePattern", filePattern) .addComponent(builder.newComponent("SizeBasedTriggeringPolicy") .addAttribute("size", "10MB"))); builder.add(builder.newRootLogger(Level.INFO) .add(builder.newAppenderRef("consoleLog")) .add(builder.newAppenderRef("fooAppender"))); // @formatter:on return builder; }
private static void addAppenderRef (final AppenderComponentBuilder appenderCom, final List <AppenderRefSetting> appenderRef, final ConfigurationBuilder <BuiltConfiguration> build) { for (final AppenderRefSetting setting : appenderRef) { final AppenderRefComponentBuilder ref = build.newAppenderRef (setting.getRef ()); addAttributes (ref, setting.getAttributes ()); appenderCom.addComponent (ref); } }
private static void addLayout (final AppenderComponentBuilder appenderCom, final LayoutSetting layout, final ConfigurationBuilder <BuiltConfiguration> build) { if (layout == null) return; final LayoutComponentBuilder layoutCom = build.newLayout (layout.getPlugin ()); addAttributes (layoutCom, layout.getAttributes ()); appenderCom.add (layoutCom); }
private void addAppenders (final ConfigurationBuilder <BuiltConfiguration> build) { for (final AppenderSetting appender : this.appenders) { final AppenderComponentBuilder appenderCom = build.newAppender (appender.getName (), appender.getPlugin ()); addAttributes (appenderCom, appender.getAttributes ()); addLayout (appenderCom, appender.getLayout (), build); addAppenderRef (appenderCom, appender.getAppenderRef (), build); addComponent (appenderCom, appender.getComponent (), build); build.add (appenderCom); } }
private <K extends ComponentBuilder <K>> void addComponent (final ComponentBuilder <K> component, final ComponentSetting setting, final ConfigurationBuilder <BuiltConfiguration> build) { if (setting == null) return; final ComponentBuilder <?> comp = build.newComponent (setting.getPlugin ()); for (final ComponentSetting c : setting.getComponents ()) { final ComponentBuilder <?> newComp = build.newComponent (c.getPlugin ()); addAttributes (newComp, c.getAttributes ()); if (!c .getComponents () .isEmpty ()) { addComponent (newComp, c, build); } comp.addComponent (newComp); } component.addComponent (comp); }
private void addRootLogger (final ConfigurationBuilder <BuiltConfiguration> build) { final RootLoggerComponentBuilder root = build.newRootLogger (this.loggers .getLevel () .getStatus ()); for (final AppenderRefSetting setting : this.loggers.getAppenderRef ()) { final AppenderRefComponentBuilder ref = build.newAppenderRef (setting.getRef ()); addAttributes (ref, setting.getAttributes ()); root.add (ref); } build.add (root); }
/** * 初始化日志配置 */ public static void initLog4j2WithoutConfigFile() { System.out.println("no local log4j2.xml file found,init logContext"); ConfigurationBuilder< BuiltConfiguration > builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setStatusLevel( Level.ERROR); builder.setConfigurationName("RollingBuilder"); // create the console appender AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout"). addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable")); builder.add( appenderBuilder ); // LayoutComponentBuilder layoutBuilder = builder.newLayout("PatternLayout") // .addAttribute("pattern", "%d [%t] %-5level: %msg%n"); // ComponentBuilder triggeringPolicy = builder.newComponent("Policies") // .addComponent(builder.newComponent("CronTriggeringPolicy").addAttribute("schedule", "0 0 0 * * ?")) // .addComponent(builder.newComponent("SizeBasedTriggeringPolicy").addAttribute("size", "100M")); // appenderBuilder = builder.newAppender("rolling", "RollingFile") // .addAttribute("fileName", "target/rolling.log") // .addAttribute("filePattern", "target/archive/rolling-%d{MM-dd-yy}.log.gz") // .add(layoutBuilder) // .addComponent(triggeringPolicy); // builder.add(appenderBuilder); builder.add(builder.newRootLogger(Level.INFO).add(builder.newAppenderRef("Stdout"))); builder.add(builder.newLogger("com.jeesuite", Level.TRACE).add(builder.newAppenderRef("Stdout")).addAttribute("additivity", false)); Configurator.initialize(builder.build()); }
@Before public void setup() { ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); String webhookUrl = System.getProperty(SLACK_WEBHOOK, System.getenv(SLACK_WEBHOOK)); assertNotNull(SLACK_WEBHOOK + " MUST NOT be null", webhookUrl); AppenderComponentBuilder appenderComponentBuilder = builder.newAppender("SlackerFoo", "Slack"); appenderComponentBuilder.addAttribute("webhookUrl", webhookUrl); appenderComponentBuilder.addAttribute("httpClientImpl", OkHttp3Client.class.getName()); appenderComponentBuilder.add(builder.newLayout("PatternLayout"). addAttribute("pattern", "%-5p - [%t] %-26.26c{1}")); builder.add(appenderComponentBuilder); builder.add(builder.newRootLogger(Level.INFO).add(builder.newAppenderRef("SlackerFoo"))); Configurator.initialize(builder.build()); }
public static void intializeLoggers() { ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setConfigurationName("logger"); RootLoggerComponentBuilder rootLogger = builder.newRootLogger(Level.DEBUG); builder.add(rootLogger); Configurator.initialize(builder.build()); }
/** * Parses a Log4j 1.2 properties configuration file in ISO 8859-1 encoding into a ConfigurationBuilder. * * @param input * InputStream to read from is assumed to be ISO 8859-1, and will not be closed. * @return the populated ConfigurationBuilder, never {@literal null} * @throws IOException * if unable to read the input * @throws ConfigurationException * if the input does not contain a valid configuration */ public ConfigurationBuilder<BuiltConfiguration> buildConfigurationBuilder(final InputStream input) throws IOException { try { properties.load(input); strSubstitutorProperties = new StrSubstitutor(properties); strSubstitutorSystem = new StrSubstitutor(System.getProperties()); final String rootCategoryValue = getLog4jValue(ROOTCATEGORY); final String rootLoggerValue = getLog4jValue(ROOTLOGGER); if (rootCategoryValue == null && rootLoggerValue == null) { // This is not a Log4j 1 properties configuration file. warn("Missing " + ROOTCATEGORY + " or " + ROOTLOGGER + " in " + input); // throw new ConfigurationException( // "Missing " + ROOTCATEGORY + " or " + ROOTLOGGER + " in " + input); } builder.setConfigurationName("Log4j1"); // DEBUG final String debugValue = getLog4jValue("debug"); if (Boolean.valueOf(debugValue)) { builder.setStatusLevel(Level.DEBUG); } // Root buildRootLogger(getLog4jValue(ROOTCATEGORY)); buildRootLogger(getLog4jValue(ROOTLOGGER)); // Appenders final Map<String, String> appenderNameToClassName = buildClassToPropertyPrefixMap(); for (final Map.Entry<String, String> entry : appenderNameToClassName.entrySet()) { final String appenderName = entry.getKey(); final String appenderClass = entry.getValue(); buildAppender(appenderName, appenderClass); } // Loggers buildLoggers("log4j.category."); buildLoggers("log4j.logger."); buildProperties(); return builder; } catch (final IllegalArgumentException e) { throw new ConfigurationException(e); } }
@Override public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) { final ConfigurationBuilder<BuiltConfiguration> builder; try (final InputStream configStream = source.getInputStream()) { builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(configStream); } catch (final IOException e) { throw new ConfigurationException("Unable to load " + source, e); } return builder.build(); }
private void addTestFixtures(final String name, final ConfigurationBuilder<BuiltConfiguration> builder) { builder.setConfigurationName(name); builder.setStatusLevel(Level.ERROR); builder.setShutdownTimeout(5000, TimeUnit.MILLISECONDS); builder.add(builder.newScriptFile("target/test-classes/scripts/filter.groovy").addIsWatched(true)); builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL) .addAttribute("level", Level.DEBUG)); final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout"). addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable")); appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY, Filter.Result.NEUTRAL).addAttribute("marker", "FLOW")); builder.add(appenderBuilder); final AppenderComponentBuilder appenderBuilder2 = builder.newAppender("Kafka", "Kafka").addAttribute("topic", "my-topic"); appenderBuilder2.addComponent(builder.newProperty("bootstrap.servers", "localhost:9092")); appenderBuilder2.add(builder.newLayout("GelfLayout"). addAttribute("host", "my-host"). addComponent(builder.newKeyValuePair("extraField", "extraValue"))); builder.add(appenderBuilder2); builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG, true). add(builder.newAppenderRef("Stdout")). addAttribute("additivity", false)); builder.add(builder.newLogger("org.apache.logging.log4j.core"). add(builder.newAppenderRef("Stdout"))); builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))); builder.addProperty("MyKey", "MyValue"); builder.add(builder.newCustomLevel("Panic", 17)); builder.setPackages("foo,bar"); }
@Test public void testXmlConstructing() throws Exception { //assumeTrue(System.lineSeparator().length() == 1); // Only run test on platforms with single character line endings (such as Linux), not on Windows final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); addTestFixtures("config name", builder); final String xmlConfiguration = builder.toXmlConfiguration(); assertEquals(expectedXml, xmlConfiguration); }
static Configuration addTestFixtures(final String name, final ConfigurationBuilder<BuiltConfiguration> builder) { builder.setConfigurationName(name); builder.setStatusLevel(Level.ERROR); builder.add(builder.newScriptFile("target/test-classes/scripts/filter.groovy").addIsWatched(true)); builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL) .addAttribute("level", Level.DEBUG)); final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout"). addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable")); appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY, Filter.Result.NEUTRAL).addAttribute("marker", "FLOW")); builder.add(appenderBuilder); final AppenderComponentBuilder appenderBuilder2 = builder.newAppender("Kafka", "Kafka").addAttribute("topic", "my-topic"); appenderBuilder2.addComponent(builder.newProperty("bootstrap.servers", "localhost:9092")); appenderBuilder2.add(builder.newLayout("GelfLayout"). addAttribute("host", "my-host"). addComponent(builder.newKeyValuePair("extraField", "extraValue"))); builder.add(appenderBuilder2); builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG, true). add(builder.newAppenderRef("Stdout")). addAttribute("additivity", false)); builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))); builder.add(builder.newCustomLevel("Panic", 17)); return builder.build(); }
@Override public ConfigurationBuilder<T> add(final RootLoggerComponentBuilder builder) { for (final Component c : loggers.getComponents()) { if (c.getPluginType().equals(LoggerConfig.ROOT)) { throw new ConfigurationException("Root Logger was previously defined"); } } return add(loggers, builder); }
@Test public void testBuilderWithScripts() throws Exception { final String script = "if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" + " return \"NoLocation\";\n" + " } else if (logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n" + " return \"Flow\";\n" + " } else {\n" + " return null;\n" + " }"; final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setStatusLevel(Level.ERROR); builder.setConfigurationName("BuilderTest"); builder.add(builder.newScriptFile("filter.groovy", "target/test-classes/scripts/filter.groovy").addIsWatched(true)); final AppenderComponentBuilder appenderBuilder = builder.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout"). addComponent(builder.newComponent("ScriptPatternSelector") .addAttribute("defaultPattern", "[%-5level] %c{1.} %C{1.}.%M.%L %msg%n") .addComponent(builder.newComponent("PatternMatch").addAttribute("key", "NoLocation") .addAttribute("pattern", "[%-5level] %c{1.} %msg%n")) .addComponent(builder.newComponent("PatternMatch").addAttribute("key", "FLOW") .addAttribute("pattern", "[%-5level] %c{1.} ====== %C{1.}.%M:%L %msg ======%n")) .addComponent(builder.newComponent("selectorScript", "Script", script).addAttribute("language", "beanshell")))); appenderBuilder.add(builder.newFilter("ScriptFilter", Filter.Result.DENY, Filter.Result.NEUTRAL).addComponent(builder.newComponent("ScriptRef").addAttribute("ref", "filter.groovy"))); builder.add(appenderBuilder); builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG). add(builder.newAppenderRef("Stdout")). addAttribute("additivity", false)); builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout"))); ctx = Configurator.initialize(builder.build()); final Configuration config = ctx.getConfiguration(); assertNotNull("No configuration", config); assertEquals("Unexpected Configuration", "BuilderTest", config.getName()); assertThat(config.getAppenders(), hasSize(equalTo(1))); assertNotNull("Filter script not found", config.getScriptManager().getScript("filter.groovy")); assertNotNull("pattern selector script not found", config.getScriptManager().getScript("selectorScript")); }
@Test public void testXmlConstructing() throws Exception { assumeTrue(System.lineSeparator().length() == 1); // Only run test on platforms with single character line endings (such as Linux), not on Windows final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); addTestFixtures("config name", builder); final String xmlConfiguration = builder.toXmlConfiguration(); assertEquals(expectedXml, xmlConfiguration); }
@Test public void testBuildConfiguration() throws Exception { try { System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); CustomConfigurationFactory.addTestFixtures("config name", builder); final Configuration configuration = builder.build(); try (LoggerContext ctx = Configurator.initialize(configuration)) { validate(configuration); } } finally { System.getProperties().remove(Constants.LOG4J_CONTEXT_SELECTOR); } }
private static void configureStatusLogger() { final ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setStatusLevel(Level.ERROR); Configurator.initialize(builder.build()); }
@Override public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) { ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder(); return createConfiguration(name, builder); }
private void addProperties (final ConfigurationBuilder <BuiltConfiguration> build) { for (final PropertySetting property : this.properties) { build.addProperty (property.getName (), property.getValue ()); } }
protected void convert(final InputStream input, final OutputStream output) throws IOException { final ConfigurationBuilder<BuiltConfiguration> builder = new Log4j1ConfigurationParser() .buildConfigurationBuilder(input); builder.writeXmlConfiguration(output); }
@Override public Configuration getConfiguration(final LoggerContext loggerContext, final String name, final URI configLocation) { final ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder(); return addTestFixtures(name, builder); }
protected ConfigurationBuilder<T> add(final Component parent, final ComponentBuilder<?> builder) { parent.getComponents().add(builder.build()); return this; }
@Override public ConfigurationBuilder<T> add(final AppenderComponentBuilder builder) { return add(appenders, builder); }
@Override public ConfigurationBuilder<T> add(final CustomLevelComponentBuilder builder) { return add(customLevels, builder); }
@Override public ConfigurationBuilder<T> add(final FilterComponentBuilder builder) { return add(filters, builder); }
@Override public ConfigurationBuilder<T> add(final ScriptComponentBuilder builder) { return add(scripts, builder); }
@Override public ConfigurationBuilder<T> add(final ScriptFileComponentBuilder builder) { return add(scripts, builder); }
@Override public ConfigurationBuilder<T> add(final LoggerComponentBuilder builder) { return add(loggers, builder); }
@Override public ConfigurationBuilder<T> addProperty(final String key, final String value) { properties.addComponent(newComponent(key, "Property", value).build()); return this; }
@Override public ConfigurationBuilder<T> setAdvertiser(final String advertiser) { this.advertiser = advertiser; return this; }
@Override public ConfigurationBuilder<T> setMonitorInterval(final String intervalSeconds) { monitorInterval = Integer.parseInt(intervalSeconds); return this; }
@Override public ConfigurationBuilder<T> setPackages(final String packages) { this.packages = packages; return this; }