Java Code Examples for ch.qos.logback.core.spi.FilterReply#NEUTRAL

The following examples show how to use ch.qos.logback.core.spi.FilterReply#NEUTRAL . 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: XodusFileDataWriterLogLevelModificator.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
@Override
public FilterReply decide(final Marker marker, final ch.qos.logback.classic.Logger logger, final Level level, final String format, final Object[] params, final Throwable t) {

    if (level.isGreaterOrEqual(Level.WARN)) {
        if (logger.getName().equals(fileDataWriterLogger.getName())) {
            if (format != null) {
                if (format.startsWith("Can't open directory channel. Log directory fsync won't be performed.")) {
                    if (first.getAndSet(false)) {
                        log.debug("Can't open directory channel. Log directory fsync won't be performed.");
                    }
                    return FilterReply.DENY;
                }
            }
        }

    }
    return FilterReply.NEUTRAL;
}
 
Example 2
Source File: NettyLogLevelModifier.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
@NotNull
private FilterReply sortOutUnsupportedOperationException(final Object[] params, final Throwable t) {
    if (t instanceof UnsupportedOperationException) {
        return FilterReply.DENY;
    }
    if (params == null) {
        return FilterReply.NEUTRAL;
    }
    final Object[] paramList = params;
    for (final Object param : paramList) {
        if (param instanceof UnsupportedOperationException) {
            return FilterReply.DENY;
        }
    }
    return FilterReply.NEUTRAL;
}
 
Example 3
Source File: Logback1027WorkaroundTurboFilter.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: GatewayEventFilter.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
	if (params != null && logger.getName().startsWith("discord4j.gateway.inbound")) {
		for (Object param : params) {
			if (param instanceof GatewayPayload) {
				GatewayPayload<?> payload = (GatewayPayload) param;
				if (Opcode.DISPATCH.equals(payload.getOp())) {
					if (excludedEvents != null) {
						if (excludedEvents.contains(payload.getType())) {
							return FilterReply.DENY;
						}
					} else if (includedEvents != null) {
						if (!includedEvents.contains(payload.getType())) {
							return FilterReply.DENY;
						}
					}
				}
			}
		}
	}
	return FilterReply.NEUTRAL;
}
 
Example 5
Source File: PrincipalLogEventFilter.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event)
{
    Subject subject = Subject.getSubject(AccessController.getContext());
    if (subject != null && subject.getPrincipals().contains(_principal))
    {
        return FilterReply.NEUTRAL;
    }
    return FilterReply.DENY;
}
 
Example 6
Source File: XodusEnvironmentImplLogLevelModificator.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(final Marker marker, final ch.qos.logback.classic.Logger logger, final Level level,
                          final String format, final Object[] params, final Throwable t) {
    if (level.isGreaterOrEqual(Level.INFO)) {

        if (logger.getName().equals(environmentalLogger.getName())) {

            if (format != null) {

                if (format.contains("transaction(s) not finished")) {
                    logger.trace(marker, format, params);
                    return FilterReply.DENY;
                } else if (format.contains("Transactions stack traces are not available")) {
                    logger.trace(marker, format, params);
                    return FilterReply.DENY;
                }
            }
        }
    }


    if (level.isGreaterOrEqual(Level.ERROR) && t != null && t.getMessage() != null && t instanceof ExodusException) {
        if (t.getMessage().contains("cleanFile") || t.getMessage().contains("There is no file by address")) {
            logger.trace(marker, "Xodus background job unable to cleanup stale data just now, trying again later");
            return FilterReply.DENY;
        }
    }

    // Let other filters decide
    return FilterReply.NEUTRAL;
}
 
Example 7
Source File: MetricBlockFilter.java    From lambda-monitoring with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
    Marker eventMarker = event.getMarker();
    if (isStarted() && eventMarker != null && eventMarker.contains(MetricPassFilter.METRIC_MARKER)) {
        return FilterReply.DENY;
    }
    return FilterReply.NEUTRAL;
}
 
Example 8
Source File: MetricPassFilter.java    From lambda-monitoring with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
    Marker eventMarker = event.getMarker();
    if (isStarted() && (eventMarker == null || !eventMarker.contains(METRIC_MARKER))) {
        return FilterReply.DENY;
    } else {
        return FilterReply.NEUTRAL;
    }
}
 
Example 9
Source File: ErrorCatcher.java    From FlareBot with MIT License 5 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
    String msg = event.getFormattedMessage();
    if (msg == null)
        msg = "null";
    if (event.getMarker() != Markers.NO_ANNOUNCE
            && FlareBot.instance() != null
            && event.getLevel() == Level.ERROR || event.getLevel() == Level.WARN) {
        String finalMsg = msg;
        if (event.getThreadName().startsWith("lava-daemon-pool")) {
            return FilterReply.NEUTRAL;
        }
        EXECUTOR.submit(() -> {
            Throwable throwable = null;
            if (event.getThrowableProxy() != null && event.getThrowableProxy() instanceof ThrowableProxy) {
                throwable = ((ThrowableProxy) event.getThrowableProxy()).getThrowable();
            }
            if (event.getLevel() == Level.WARN) {
                // Warnings should not have a throwable!
                MessageUtils.sendWarningMessage(finalMsg, Constants.getErrorLogChannel());
                return;
            }
            if (throwable != null) {
                if (event.getMarker() == Markers.TAG_DEVELOPER)
                    MessageUtils.sendFatalException(finalMsg, throwable, Constants.getErrorLogChannel());
                else
                    MessageUtils.sendException(finalMsg, throwable, Constants.getErrorLogChannel());
            } else {
                if (event.getMarker() == Markers.TAG_DEVELOPER)
                    MessageUtils.sendFatalErrorMessage(finalMsg, Constants.getErrorLogChannel());
                else
                    MessageUtils.sendErrorMessage(finalMsg, Constants.getErrorLogChannel());
            }
        });
    }
    return FilterReply.NEUTRAL;
}
 
Example 10
Source File: MarkerFilter.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
  if (!isStarted()) {
    return FilterReply.NEUTRAL;
  }

  Marker currentMarker = event.getMarker();

  if (currentMarker == null || !marker.equals(currentMarker.getName())) {
    return onMismatch;
  } else {
    return onMatch;
  }
}
 
Example 11
Source File: LogbackMetrics.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
    // When filter is asked for decision for an isDebugEnabled call or similar test, there is no message (ie format) 
    // and no intention to log anything with this call. We will not increment counters and can return immediately and
    // avoid the relatively expensive ThreadLocal access below. See also logbacks Logger.callTurboFilters().
    if (format == null) {
        return FilterReply.NEUTRAL;
    }

    Boolean ignored = LogbackMetrics.ignoreMetrics.get();
    if (ignored != null && ignored) {
        return FilterReply.NEUTRAL;
    }

    // cannot use logger.isEnabledFor(level), as it would cause a StackOverflowError by calling this filter again!
    if (level.isGreaterOrEqual(logger.getEffectiveLevel())) {
        switch (level.toInt()) {
            case Level.ERROR_INT:
                errorCounter.increment();
                break;
            case Level.WARN_INT:
                warnCounter.increment();
                break;
            case Level.INFO_INT:
                infoCounter.increment();
                break;
            case Level.DEBUG_INT:
                debugCounter.increment();
                break;
            case Level.TRACE_INT:
                traceCounter.increment();
                break;
        }
    }

    return FilterReply.NEUTRAL;
}
 
Example 12
Source File: UseridFilter.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
    if (MDC.get("userid") == null) {
        MDC.put("userid", System.getProperty("user.name"));
    }

    return FilterReply.NEUTRAL;
}
 
Example 13
Source File: LogLevelInfoFilter.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {

    if (isFilterActive
        && isLevelInfoOrLower(level)
        && isInternalLogger(logger)
        && ( marker == null || !marker.getName().equals(APIML_MARKER))
    ) {
        return FilterReply.DENY;
    }
    return FilterReply.NEUTRAL;
}
 
Example 14
Source File: LoggerNameAndLevelFilter.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
private FilterReply getWildCardLoggerFilterReply(final Level eventLevel)
{
    if (eventLevel.isGreaterOrEqual(_level))
    {
        return FilterReply.ACCEPT;
    }
    else
    {
        return FilterReply.NEUTRAL;
    }
}
 
Example 15
Source File: ApimlDependencyLogHider.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
    if (!isFilterActive || format == null || isLowThanInfoLevel(logger.getEffectiveLevel())) {
        return FilterReply.NEUTRAL;
    }

    if (t != null) {
        format += Stream.of(ExceptionUtils.getStackFrames(t)).collect(Collectors.joining());
    }

    return getFilterReply(format);
}
 
Example 16
Source File: XodusFileDataWriterLogLevelModificatorTest.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@NotNull
private Filter<ILoggingEvent> createFilter(final CountDownLatch countDownLatch, final String text) {
    return new Filter<ILoggingEvent>() {
        @Override
        public FilterReply decide(final ILoggingEvent event) {
            if (event.getLevel().equals(Level.DEBUG)) {
                if (event.getFormattedMessage().equals(text)) {
                    countDownLatch.countDown();
                    return FilterReply.NEUTRAL;
                }
            }
            return FilterReply.NEUTRAL;
        }
    };
}
 
Example 17
Source File: VirtualHostLogEventExcludingFilter.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event)
{
    if (!_brokerLogger.isVirtualHostLogEventExcluded()  || !subjectContainsVirtualHostPrincipal())
    {
        return FilterReply.NEUTRAL;
    }
    return FilterReply.DENY;
}
 
Example 18
Source File: XodusEnvironmentImplLogLevelModificatorTest.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@NotNull
private Filter<ILoggingEvent> createFilter(final CountDownLatch countDownLatch, final String text) {
    return new Filter<ILoggingEvent>() {
        @Override
        public FilterReply decide(final ILoggingEvent event) {
            if (event.getLevel().equals(Level.TRACE)) {
                if (event.getFormattedMessage().equals(text)) {
                    countDownLatch.countDown();
                    return FilterReply.NEUTRAL;
                }
            }
            return FilterReply.NEUTRAL;
        }
    };
}
 
Example 19
Source File: PredicateAndLoggerNameAndLevelFilter.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter<ILoggingEvent> createFilter(final String loggerName)
{
    final Filter<ILoggingEvent> filter = super.createFilter(loggerName);
    return new Filter<ILoggingEvent>()
    {
        @Override
        public FilterReply decide(final ILoggingEvent event)
        {
            final FilterReply result = filter.decide(event);
            if (result == FilterReply.ACCEPT)
            {
                if (_predicate.evaluate(event))
                {
                    return FilterReply.ACCEPT;
                }
                else
                {
                    return FilterReply.NEUTRAL;
                }
            }
            else
            {
                return result;
            }
        }
    };
}
 
Example 20
Source File: Filter.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public FilterReply decide(ILoggingEvent event) {
    if (event.getMarker() == Markers.NO_ANNOUNCE) return FilterReply.DENY;
    return FilterReply.NEUTRAL;
}