ch.qos.logback.core.spi.FilterReply Java Examples
The following examples show how to use
ch.qos.logback.core.spi.FilterReply.
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: AbstractVirtualHostTest.java From qpid-broker-j with Apache License 2.0 | 7 votes |
private void assertActionProducesLogMessage(final Runnable action, final String loggerName, final Level logLevel, final String message) throws Exception { final CountDownLatch logMessageReceivedLatch = new CountDownLatch(1); ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); ListAppender<ILoggingEvent> appender = new ListAppender<>(); appender.addFilter(new Filter<ILoggingEvent>() { @Override public FilterReply decide(final ILoggingEvent event) { if (event.getLoggerName().equals(loggerName) && event.getLevel().equals(logLevel) && event.getFormattedMessage().contains(message)) { logMessageReceivedLatch.countDown(); } return FilterReply.NEUTRAL; } }); appender.setContext(rootLogger.getLoggerContext()); appender.start(); rootLogger.addAppender(appender); action.run(); assertTrue("Did not receive expected log message", logMessageReceivedLatch.await(2, TimeUnit.SECONDS)); }
Example #2
Source File: LoggingConfiguration.java From flair-registry with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #3
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #4
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #5
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #6
Source File: LoggingConfiguration.java From java-microservices-examples with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); context.getLoggerList().forEach((logger) -> { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME) && !(appender.getName().equals(CONSOLE_APPENDER_NAME) && this.jHipsterProperties.getLogging().isUseJsonFormat())) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } }); }
Example #7
Source File: LoggingConfiguration.java From java-microservices-examples with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); context.getLoggerList().forEach((logger) -> { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME) && !(appender.getName().equals(CONSOLE_APPENDER_NAME) && this.jHipsterProperties.getLogging().isUseJsonFormat())) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } }); }
Example #8
Source File: LoggerNameAndLevelFilterTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testDecideForRootLoggerName() throws Exception { LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter(Logger.ROOT_LOGGER_NAME, Level.INFO); ILoggingEvent event = mock(ILoggingEvent.class); when(event.getLevel()).thenReturn(Level.INFO); when(event.getLoggerName()).thenReturn("org.apache.qpid.server.foo"); assertEquals("Unexpected reply for matching log level and arbitrary logger name", FilterReply.ACCEPT, filter.decide(event)); when(event.getLoggerName()).thenReturn("org.apache.qpid.foo"); assertEquals("Unexpected reply for matching log level and arbitrary logger name", FilterReply.ACCEPT, filter.decide(event)); when(event.getLevel()).thenReturn(Level.DEBUG); assertEquals("Unexpected reply for non matching log level", FilterReply.NEUTRAL, filter.decide(event)); }
Example #9
Source File: LoggingConfiguration.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #10
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #11
Source File: LoggingConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #12
Source File: LogLevelInfoFilterTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void packageFilterTest() { Map<String, Boolean> loggerMap = new HashMap<>(); loggerMap.put("org.zowe.apiml.product.logging.LogLevelFilterTest", true); loggerMap.put("org.zowe.apiml.security.common.config.AuthConfigurationProperties", true); loggerMap.put("com.amazonaws", false); loggerMap.put("bucharest.org.zowe.apiml", false); loggerMap.put("ORG.ZOWE.APIML.CRAZYPEOPLE", false); loggerMap.forEach((loggerName, shouldFilter) -> { org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(loggerName); FilterReply reply = filterInstance.decide(null, (ch.qos.logback.classic.Logger) logger, Level.DEBUG, "", null, null); assertEquals("Logger of name " + logger.getName() + " is not filtered correctly", shouldFilter ? FilterReply.DENY : FilterReply.NEUTRAL, reply); }); }
Example #13
Source File: Logback1027WorkaroundTurboFilterTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testInitCauseRecursion() throws Exception { // https://www.ibm.com/developerworks/community/forums/html/topic?id=8482d948-665c-47a2-862e-457e49ac71a4&ps=25 assumeThat("(QPID-7955) Behaviourial difference between the IBM JDK and the Open JDK", getJvmVendor(), not(anyOf(equalTo(OPENJDK), equalTo(IBM)))); Exception e1 = new Exception(); Exception e2 = new Exception(); e2.initCause(e1); e1.initCause(e2); final FilterReply reply = doDecide(e1); assertEquals(FilterReply.DENY, reply); assertEquals((long) 1, (long) _snoopingAppender.getEvents().size()); }
Example #14
Source File: LoggerNameAndLevelFilterTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testDecideForEmptyLoggerName() throws Exception { LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter("", Level.INFO); ILoggingEvent event = mock(ILoggingEvent.class); when(event.getLevel()).thenReturn(Level.INFO); when(event.getLoggerName()).thenReturn("org.apache.qpid.server.foo"); assertEquals("Unexpected reply for matching log level and arbitrary logger name", FilterReply.ACCEPT, filter.decide(event)); when(event.getLoggerName()).thenReturn("org.apache.qpid.foo"); assertEquals("Unexpected reply for matching log level and arbitrary logger namel", FilterReply.ACCEPT, filter.decide(event)); when(event.getLevel()).thenReturn(Level.DEBUG); assertEquals("Unexpected reply for non matching log level", FilterReply.NEUTRAL, filter.decide(event)); }
Example #15
Source File: Logback1027WorkaroundTurboFilter.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Override public FilterReply decide(final Marker marker, final Logger logger, final Level level, final String format, final Object[] params, final Throwable t) { if (t != null && hasRecursiveThrowableReference(t, null)) { final int locationAwareLoggerInteger = Level.toLocationAwareLoggerInteger(level); logger.log(marker, logger.getName(), locationAwareLoggerInteger, format, params, new StringifiedException(t)); return FilterReply.DENY; } return FilterReply.NEUTRAL; }
Example #16
Source File: LoggingConfiguration.java From e-commerce-microservice with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #17
Source File: Logback1027WorkaroundTurboFilterTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testSuppressedExceptionRecursion() { // https://www.ibm.com/developerworks/community/forums/html/topic?id=8482d948-665c-47a2-862e-457e49ac71a4&ps=25 assumeThat("(QPID-7955) Behaviourial difference between the IBM JDK and the Open JDK", getJvmVendor(), not(anyOf(equalTo(OPENJDK), equalTo(IBM)))); Exception e1 = new Exception(); Exception e2 = new Exception(); e2.addSuppressed(e1); e1.addSuppressed(e2); final FilterReply reply = doDecide(e1); assertEquals(FilterReply.DENY, reply); final List<ILoggingEvent> events = _snoopingAppender.getEvents(); assertEquals((long) 1, (long) events.size()); assertLoggingEvent(events.get(0)); }
Example #18
Source File: NettyLogLevelModifier.java From hivemq-community-edition with Apache License 2.0 | 6 votes |
@NotNull private FilterReply traceAndSortOutUnsupportedOperationException(final Marker marker, final Logger logger, final String format, final Object[] params, final Throwable t) { if (t instanceof UnsupportedOperationException) { return FilterReply.DENY; } if (params == null) { logger.trace(marker, format, params); return FilterReply.DENY; } final Object[] paramList = params; for (final Object param : paramList) { if (param instanceof UnsupportedOperationException) { return FilterReply.DENY; } } logger.trace(marker, format, params); return FilterReply.DENY; }
Example #19
Source File: LoggerNameAndLevelFilterTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testDecideForWildcardLoggerName() throws Exception { LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter("org.apache.qpid.server.*", Level.INFO); ILoggingEvent event = mock(ILoggingEvent.class); when(event.getLevel()).thenReturn(Level.INFO); when(event.getLoggerName()).thenReturn("org.apache.qpid.server.foo"); assertEquals("Unexpected reply for matching logger name and log level", FilterReply.ACCEPT, filter.decide(event)); when(event.getLoggerName()).thenReturn("org.apache.qpid.foo"); assertEquals("Unexpected reply for non matching logger name but matching log level", FilterReply.NEUTRAL, filter.decide(event)); when(event.getLoggerName()).thenReturn("org.apache.qpid.server.foo"); when(event.getLevel()).thenReturn(Level.DEBUG); assertEquals("Unexpected reply for matching logger name but non matching log level", FilterReply.NEUTRAL, filter.decide(event)); }
Example #20
Source File: LoggingConfiguration.java From e-commerce-microservice with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #21
Source File: LoggingConfiguration.java From e-commerce-microservice with Apache License 2.0 | 6 votes |
private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } }
Example #22
Source File: LoggerNameAndLevelFilterTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testDecideForTurnedOffLogger() throws Exception { LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter("org.apache.qpid", Level.OFF); ILoggingEvent event = mock(ILoggingEvent.class); when(event.getLevel()).thenReturn(Level.WARN); when(event.getLoggerName()).thenReturn("org.apache.qpid"); assertEquals("Unexpected reply for matching log level and same logger name", FilterReply.DENY, filter.decide(event)); when(event.getLoggerName()).thenReturn("org.apache.qpid.foo"); assertEquals("Unexpected reply for matching log level and not same logger name", FilterReply.NEUTRAL, filter.decide(event)); }
Example #23
Source File: ApimlDependencyLogHiderTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void testDecide_whenIgnoredMessagesArePresent() { logger.setLevel(Level.INFO); Map<String, Boolean> logMessages = new HashMap<>(); logMessages.put("Tomcat initialized with port(s): 10011 (https)", true); logMessages.put("The replica size seems to be empty. Check the route 53 DNS Registry", true); logMessages.put("Peer wants us to take the instance information from it, since the timestamp differs," + "Id : {} My Timestamp : {}, Peer's timestamp: {}", true); logMessages.put("The replication of task {} failed with response code {}", true); logMessages.put("Test message", false); logMessages.forEach((logMessage, shouldBeIgnored) -> { FilterReply actualFilterReply = apimlDependencyLogHider.decide(null, logger, null, logMessage, null, null); FilterReply expectedFilterReply = shouldBeIgnored ? FilterReply.DENY : FilterReply.NEUTRAL; assertEquals("Log levels are not same", expectedFilterReply, actualFilterReply); }); }
Example #24
Source File: Logback1027WorkaroundTurboFilterTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testOneException() { Exception e = new Exception(); final FilterReply reply = doDecide(e); assertEquals(FilterReply.NEUTRAL, reply); assertEquals((long) 0, (long) _snoopingAppender.getEvents().size()); }
Example #25
Source File: ItemFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Decides what to do with logging event.<br> * This method accepts only log events that contain exceptions. * * @param loggingEvent * log event that is going to be filtred. * @return {@link org.apache.log4j.spi.Filter#ACCEPT} if admin command, * {@link org.apache.log4j.spi.Filter#DENY} otherwise */ @Override public FilterReply decide(ILoggingEvent loggingEvent) { Object message = loggingEvent.getMessage(); if (((String) message).startsWith("[ITEM]")) { return FilterReply.ACCEPT; } return FilterReply.DENY; }
Example #26
Source File: DropFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Decides what to do with logging event.<br> * This method accepts only log events that contain exceptions. * * @param loggingEvent * log event that is going to be filtred. * @return {@link org.apache.log4j.spi.Filter#ACCEPT} if admin command, * {@link org.apache.log4j.spi.Filter#DENY} otherwise */ @Override public FilterReply decide(ILoggingEvent loggingEvent) { Object message = loggingEvent.getMessage(); if (((String) message).startsWith("[DROP]")) { return FilterReply.ACCEPT; } return FilterReply.DENY; }
Example #27
Source File: GmAuditFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Decides what to do with logging event.<br> * This method accepts only log events that contain exceptions. * * @param loggingEvent * log event that is going to be filtred. * @return {@link org.apache.log4j.spi.Filter#ACCEPT} if admin command, * {@link org.apache.log4j.spi.Filter#DENY} otherwise */ @Override public FilterReply decide(ILoggingEvent loggingEvent) { Object message = loggingEvent.getMessage(); if (((String) message).startsWith("[ADMIN COMMAND]")) { return FilterReply.ACCEPT; } return FilterReply.DENY; }
Example #28
Source File: AutoGroupFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Decides what to do with logging event.<br> * This method accepts only log events that contain exceptions. * * @param loggingEvent * log event that is going to be filtred. * @return {@link org.apache.log4j.spi.Filter#ACCEPT} if admin command, * {@link org.apache.log4j.spi.Filter#DENY} otherwise */ @Override public FilterReply decide(ILoggingEvent loggingEvent) { Object message = loggingEvent.getMessage(); if (((String) message).startsWith("[AUTOGROUPSERVICE]")) { return FilterReply.ACCEPT; } return FilterReply.DENY; }
Example #29
Source File: ChatLogFilter.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Decides what to do with logging event.<br> * This method accepts only log events that contain exceptions. * * @param loggingEvent * log event that is going to be filtred. * @return {@link org.apache.log4j.spi.Filter#ACCEPT} if chatlog, * {@link org.apache.log4j.spi.Filter#DENY} otherwise */ @Override public FilterReply decide(ILoggingEvent loggingEvent) { Object message = loggingEvent.getMessage(); if (((String) message).startsWith("[MESSAGE]")) { return FilterReply.ACCEPT; } return FilterReply.DENY; }
Example #30
Source File: AccessLogFilter.java From secrets-proxy with Apache License 2.0 | 5 votes |
@Override public FilterReply decide(AccessEvent event) { if (!isStarted()) { return NEUTRAL; } if (paths.stream().anyMatch(path -> event.getRequestURI().matches(path))) { return onMatch; } else { return onMismatch; } }