org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder Java Examples
The following examples show how to use
org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder.
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: PropertiesConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private FilterComponentBuilder createFilter(final String key, final Properties properties) { final String type = (String) properties.remove(CONFIG_TYPE); if (Strings.isEmpty(type)) { throw new ConfigurationException("No type attribute provided for Appender " + key); } final String onMatch = (String) properties.remove(AbstractFilterBuilder.ATTR_ON_MATCH); final String onMismatch = (String) properties.remove(AbstractFilterBuilder.ATTR_ON_MISMATCH); final FilterComponentBuilder filterBuilder = builder.newFilter(type, onMatch, onMismatch); return processRemainingProperties(filterBuilder, properties); }
Example #2
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(); }
Example #3
Source File: DefaultAppenderRefComponentBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public AppenderRefComponentBuilder add(final FilterComponentBuilder builder) { return addComponent(builder); }
Example #4
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 #5
Source File: DefaultAppenderComponentBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public AppenderComponentBuilder add(final FilterComponentBuilder builder) { return addComponent(builder); }
Example #6
Source File: DefaultCompositeFilterComponentBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public CompositeFilterComponentBuilder add(final FilterComponentBuilder builder) { return addComponent(builder); }
Example #7
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public ConfigurationBuilder<T> add(final FilterComponentBuilder builder) { return add(filters, builder); }
Example #8
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public FilterComponentBuilder newFilter(final String type, final Filter.Result onMatch, final Filter.Result onMismatch) { return new DefaultFilterComponentBuilder(this, type, onMatch.name(), onMismatch.name()); }
Example #9
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public FilterComponentBuilder newFilter(final String type, final String onMatch, final String onMismatch) { return new DefaultFilterComponentBuilder(this, type, onMatch, onMismatch); }
Example #10
Source File: DefaultLoggerComponentBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public LoggerComponentBuilder add(final FilterComponentBuilder builder) { return addComponent(builder); }
Example #11
Source File: LoggingConfigurationFactory.java From luna with MIT License | 3 votes |
/** * Returns the filter for an appender with {@code minLevel} and {@code maxLevel}. * * @param builder The builder. * @param minLevel The minimum logging level. * @param maxLevel The maximum logging level. * @return The filter. */ private FilterComponentBuilder getLevelRangeFilter(ConfigurationBuilder<BuiltConfiguration> builder, String minLevel, String maxLevel) { return builder.newFilter("LevelRangeFilter", Result.ACCEPT, Result.DENY). addAttribute("minLevel", minLevel). addAttribute("maxLevel", maxLevel); }