Java 类org.apache.logging.log4j.core.filter.RegexFilter 实例源码

项目:logging-log4j2    文件:CompositeConfigurationTest.java   
@Test
public void testAppenderRefFilterMerge() {
    final LoggerContextRule lcr = new LoggerContextRule(
            "classpath:log4j-comp-logger-ref.xml,log4j-comp-logger-ref.json");
    final Statement test = new Statement() {
        @Override
        public void evaluate() throws Throwable {
            final CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();

            final List<AppenderRef> appenderRefList = config.getLogger("cat1").getAppenderRefs();
            final AppenderRef appenderRef = getAppenderRef(appenderRefList, "STDOUT");
            assertTrue("Expected cat1 STDOUT appenderRef to have a regex filter",
                    appenderRef.getFilter() != null && appenderRef.getFilter() instanceof RegexFilter);
        }
    };
    runTest(lcr, test);
}
项目:datarouter    文件:TestDatarouterLog4j2Configuration.java   
public TestDatarouterParentLog4j2Configuration() throws IllegalAccessException{
    addFilter(RegexFilter.createFilter(".*password.*", null, true, Result.DENY, Result.NEUTRAL));

    FileAppender testFileAppender = Log4j2Configurator.createFileAppender(TEST_APPENDER_NAME, TEST_FILE_NAME,
            defaultPattern);
    addAppender(testFileAppender);
    addLoggerConfig(getClass().getPackage().getName(), Level.ALL, false, testFileAppender);
}
项目:logging-log4j2    文件:CompositeConfigurationTest.java   
@Test
public void compositeLogger() {
    final LoggerContextRule lcr = new LoggerContextRule("classpath:log4j-comp-logger.xml,log4j-comp-logger.json");
    final Statement test = new Statement() {
        @Override
        public void evaluate() throws Throwable {
            final CompositeConfiguration config = (CompositeConfiguration) lcr.getConfiguration();
            Map<String, Appender> appendersMap = config.getLogger("cat1").getAppenders();
            assertEquals("Expected 2 Appender references for cat1 but got " + appendersMap.size(), 2,
                    appendersMap.size());
            assertTrue(appendersMap.get("STDOUT") instanceof ConsoleAppender);

            Filter loggerFilter = config.getLogger("cat1").getFilter();
            assertTrue(loggerFilter instanceof RegexFilter);
            assertEquals(loggerFilter.getOnMatch(), Filter.Result.DENY);

            appendersMap = config.getLogger("cat2").getAppenders();
            assertEquals("Expected 1 Appender reference for cat2 but got " + appendersMap.size(), 1,
                    appendersMap.size());
            assertTrue(appendersMap.get("File") instanceof FileAppender);

            appendersMap = config.getLogger("cat3").getAppenders();
            assertEquals("Expected 1 Appender reference for cat3 but got " + appendersMap.size(), 1,
                    appendersMap.size());
            assertTrue(appendersMap.get("File") instanceof FileAppender);

            appendersMap = config.getRootLogger().getAppenders();
            assertEquals("Expected 2 Appender references for the root logger but got " + appendersMap.size(), 2,
                    appendersMap.size());
            assertTrue(appendersMap.get("File") instanceof FileAppender);
            assertTrue(appendersMap.get("STDOUT") instanceof ConsoleAppender);
        }
    };
    runTest(lcr, test);
}
项目:elasticsearch_my    文件:InternalEngineTests.java   
MockAppender(final String name) throws IllegalAccessException {
    super(name, RegexFilter.createFilter(".*(\n.*)*", new String[0], false, null, null), null);
}
项目:elasticsearch_my    文件:MergeSchedulerSettingsTests.java   
MockAppender(final String name) throws IllegalAccessException {
    super(name, RegexFilter.createFilter(".*(\n.*)*", new String[0], false, null, null), null);
}
项目:elasticsearch_my    文件:MockLogAppender.java   
public MockLogAppender() throws IllegalAccessException {
    super("mock", RegexFilter.createFilter(".*(\n.*)*", new String[0], false, null, null), null);
    expectations = new ArrayList<>();
}
项目:NPlugins    文件:Log4jFilterManager.java   
@Override
public void addRegexFilter(final String regex) {
    this.addFilter(RegexFilter.createFilter(regex, "FALSE", "DENY", "NEUTRAL"));
}