org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder Java Examples
The following examples show how to use
org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder.
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: LogUtil.java From ldbc_graphalytics with Apache License 2.0 | 5 votes |
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()); }
Example #2
Source File: Log4j2ConfigurationFactory.java From apm-agent-java with Apache License 2.0 | 5 votes |
public Configuration getConfiguration() { ConfigurationBuilder<BuiltConfiguration> builder = newConfigurationBuilder(); builder.setStatusLevel(Level.ERROR) .setConfigurationName("ElasticAPM"); Level level = Level.valueOf(getValue(LOG_LEVEL_KEY, sources, getValue(DEPRECATED_LOG_LEVEL_KEY, sources, Level.INFO.toString()))); RootLoggerComponentBuilder rootLogger = builder.newRootLogger(level); List<AppenderComponentBuilder> appenders = createAppenders(builder); for (AppenderComponentBuilder appender : appenders) { rootLogger.add(builder.newAppenderRef(appender.getName())); } builder.add(rootLogger); return builder.build(); }
Example #3
Source File: Log4j1ConfigurationParser.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private void buildRootLogger(final String rootLoggerValue) { if (rootLoggerValue == null) { return; } final String[] rootLoggerParts = rootLoggerValue.split(COMMA_DELIMITED_RE); final String rootLoggerLevel = getLevelString(rootLoggerParts, Level.ERROR.name()); final RootLoggerComponentBuilder loggerBuilder = builder.newRootLogger(rootLoggerLevel); // final String[] sortedAppenderNames = Arrays.copyOfRange(rootLoggerParts, 1, rootLoggerParts.length); Arrays.sort(sortedAppenderNames); for (final String appender : sortedAppenderNames) { loggerBuilder.add(builder.newAppenderRef(appender)); } builder.add(loggerBuilder); }
Example #4
Source File: Log4j1ConfigurationParser.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private void buildRootLogger(final String rootLoggerValue) { if (rootLoggerValue == null) { return; } final String[] rootLoggerParts = rootLoggerValue.split(COMMA_DELIMITED_RE); final String rootLoggerLevel = getLevelString(rootLoggerParts, Level.ERROR.name()); final RootLoggerComponentBuilder loggerBuilder = builder.newRootLogger(rootLoggerLevel); // final String[] sortedAppenderNames = Arrays.copyOfRange(rootLoggerParts, 1, rootLoggerParts.length); Arrays.sort(sortedAppenderNames); for (final String appender : sortedAppenderNames) { loggerBuilder.add(builder.newAppenderRef(appender)); } builder.add(loggerBuilder); }
Example #5
Source File: PropertiesConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private RootLoggerComponentBuilder createRootLogger(final Properties properties) { final String level = Strings.trimToNull((String) properties.remove("level")); final String type = (String) properties.remove(CONFIG_TYPE); final String location = (String) properties.remove("includeLocation"); final boolean includeLocation; final RootLoggerComponentBuilder loggerBuilder; if (type != null) { if (type.equalsIgnoreCase("asyncRoot")) { if (location != null) { includeLocation = Boolean.parseBoolean(location); loggerBuilder = builder.newAsyncRootLogger(level, includeLocation); } else { loggerBuilder = builder.newAsyncRootLogger(level); } } else { throw new ConfigurationException("Unknown Logger type for root logger" + type); } } else { if (location != null) { includeLocation = Boolean.parseBoolean(location); loggerBuilder = builder.newRootLogger(level, includeLocation); } else { loggerBuilder = builder.newRootLogger(level); } } addLoggersToComponent(loggerBuilder, properties); return addFiltersToComponent(loggerBuilder, properties); }
Example #6
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@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); }
Example #7
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newRootLogger(final String level, final boolean includeLocation) { return new DefaultRootLoggerComponentBuilder(this, level, includeLocation); }
Example #8
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newRootLogger(final String level) { return new DefaultRootLoggerComponentBuilder(this, level); }
Example #9
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newRootLogger(final Level level, final boolean includeLocation) { return new DefaultRootLoggerComponentBuilder(this, level.toString(), includeLocation); }
Example #10
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newRootLogger(final Level level) { return new DefaultRootLoggerComponentBuilder(this, level.toString()); }
Example #11
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newRootLogger(boolean includeLocation) { return new DefaultRootLoggerComponentBuilder(this, null, includeLocation); }
Example #12
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newRootLogger() { return new DefaultRootLoggerComponentBuilder(this, null); }
Example #13
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newAsyncRootLogger(final String level, final boolean includeLocation) { return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot", includeLocation); }
Example #14
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newAsyncRootLogger(final String level) { return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot"); }
Example #15
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newAsyncRootLogger(final Level level, final boolean includeLocation) { return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot", includeLocation); }
Example #16
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newAsyncRootLogger(final Level level) { return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot"); }
Example #17
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newAsyncRootLogger(boolean includeLocation) { return new DefaultRootLoggerComponentBuilder(this, null, "AsyncRoot", includeLocation); }
Example #18
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder newAsyncRootLogger() { return new DefaultRootLoggerComponentBuilder(this, "AsyncRoot"); }
Example #19
Source File: DefaultRootLoggerComponentBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder add(final FilterComponentBuilder builder) { return addComponent(builder); }
Example #20
Source File: DefaultRootLoggerComponentBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public RootLoggerComponentBuilder add(final AppenderRefComponentBuilder builder) { return addComponent(builder); }
Example #21
Source File: CustomConfigurationFactory.java From tutorials with MIT License | 4 votes |
static Configuration createConfiguration(final String name, ConfigurationBuilder<BuiltConfiguration> builder) { AppenderComponentBuilder console = builder.newAppender("Stdout", "Console"); LayoutComponentBuilder layout = builder.newLayout("PatternLayout") .addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"); console.add(layout); FilterComponentBuilder filter = builder.newFilter("MarkerFilter", Filter.Result.ACCEPT, Filter.Result.DENY); filter.addAttribute("marker", "FLOW"); console.add(filter); builder.add(console); ComponentBuilder triggeringPolicies = builder.newComponent("Policies") .addComponent(builder.newComponent("CronTriggeringPolicy") .addAttribute("schedule", "0 0 0 * * ?")) .addComponent(builder.newComponent("SizeBasedTriggeringPolicy") .addAttribute("size", "100M")); AppenderComponentBuilder rollingFile = builder.newAppender("rolling", "RollingFile"); rollingFile.addAttribute("fileName", "target/rolling.log"); rollingFile.addAttribute("filePattern", "target/archive/rolling-%d{MM-dd-yy}.log.gz"); rollingFile.add(layout); rollingFile.addComponent(triggeringPolicies); builder.add(rollingFile); AppenderComponentBuilder file = builder.newAppender("FileSystem", "File"); file.addAttribute("fileName", "target/logging.log"); file.add(layout); builder.add(file); LoggerComponentBuilder logger = builder.newLogger("com", Level.DEBUG); logger.add(builder.newAppenderRef("Stdout")); logger.add(builder.newAppenderRef("rolling")); logger.add(builder.newAppenderRef("FileSystem")); logger.addAttribute("additivity", false); builder.add(logger); RootLoggerComponentBuilder rootLogger = builder.newRootLogger(Level.ERROR); rootLogger.add(builder.newAppenderRef("Stdout")); rootLogger.add(builder.newAppenderRef("rolling")); // rootLogger.add(builder.newAppenderRef("syslogAppender")); rootLogger.add(builder.newAppenderRef("FileSystem")); rootLogger.addAttribute("additivity", false); builder.add(rootLogger); try { builder.writeXmlConfiguration(System.out); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return builder.build(); }