本文整理汇总了Java中ch.qos.logback.core.spi.FilterReply类的典型用法代码示例。如果您正苦于以下问题:Java FilterReply类的具体用法?Java FilterReply怎么用?Java FilterReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FilterReply类属于ch.qos.logback.core.spi包,在下文中一共展示了FilterReply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(final ILoggingEvent event) {
String marker = MDC.get(MDC_MARKER_ID);
if (PROGRESS.getName().equals(marker)) {
// store the progress value in the threadlocal
TaskLoggerHelper.progress(toTaskLoggerEvent(event));
}
if (MDC.get(LOGBACK_TASK_DISCRIMINATOR_ID) == null) {
// not executing in a task...
return DENY;
}
if (NEXUS_LOG_ONLY.getName().equals(marker) || INTERNAL_PROGRESS.getName().equals(marker)) {
// not meant for task log
return DENY;
}
return NEUTRAL;
}
示例2: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t)
{
//System.out.println("** Being called "+logger+"**"+level+"**"+marker);
ConfigValueTuple override = loggerOverrides.get(logger);
if(override != null)
{
Level configLevel = Level.toLevel(override.getLevel());
if(level.isGreaterOrEqual(configLevel))
return FilterReply.ACCEPT;
else
return FilterReply.DENY;
}
else
return FilterReply.NEUTRAL;
}
示例3: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
// cannot use logger.isEnabledFor(level), as it would cause a StackOverflowError by calling this filter again!
if(level.isGreaterOrEqual(logger.getEffectiveLevel()) && format != null) {
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;
}
示例4: setMetricsMarkerLogbackFilter
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
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();
}
}
}
}
示例5: postInvoke
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public void postInvoke(Request request, Response response)
throws IOException, ServletException {
final HttpServletRequest httpRequest = (HttpServletRequest) request.getRequest();
try {
CatalinaAdapter adapter = new CatalinaAdapter(request, response);
IAccessEvent accessEvent = new AccessEvent(httpRequest, (HttpServletResponse) response.getResponse(),
adapter);
if (ctx.getFilterChainDecision(accessEvent) == FilterReply.DENY) {
return;
}
// TODO better tion handling
ctx.callAppenders(accessEvent);
} finally {
httpRequest.removeAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
}
}
示例6: setMetricsMarkerLogbackFilter
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
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();
}
}
}
}
示例7: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(ILoggingEvent event)
{
int xx = event.getLevel().levelInt;
int xx1 = Level.ERROR.toInt(); //error:40000, warn:30000, info:20000
if (xx >= xx1)
{
JFrameMain.getInstance().getMsgTextArea().append(event.getFormattedMessage() + System.lineSeparator());
}
return FilterReply.ACCEPT;
}
示例8: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(ILoggingEvent event) {
if (event.getFormattedMessage().contains("Received 404 error, please notify the developer and include the URL ("))
return FilterReply.DENY;
if (event.getMarker() != Markers.NO_ANNOUNCE && Launcher.getInstance().getClient().isReady() && event.getLevel() == Level.ERROR) {
String msg = event.getFormattedMessage();
if (event.getThrowableProxy() != null && event.getThrowableProxy() instanceof ThrowableProxy) {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
Throwable throwable = ((ThrowableProxy) event.getThrowableProxy()).getThrowable();
if (throwable != null) {
msg += ' ';
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
msg += sw.toString();
pw.close();
}
}
Messages.send(msg, Launcher.getInstance().getClient().getChannelByID("233632081110892546"));
}
return FilterReply.NEUTRAL;
}
示例9: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(ILoggingEvent event) {
String msg = event.getFormattedMessage();
if (msg.startsWith("Received 40")) {
return FilterReply.DENY;
}
if (msg.startsWith("Attempt to send message on closed")) {
return FilterReply.DENY;
}
if (event.getMarker() != Markers.NO_ANNOUNCE
&& FlareBot.getInstance().getClient() != null
&& FlareBot.getInstance().getClient().isReady()
&& event.getLevel() == Level.ERROR) {
EXECUTOR.submit(() -> {
Throwable throwable = null;
if (event.getThrowableProxy() != null && event.getThrowableProxy() instanceof ThrowableProxy) {
throwable = ((ThrowableProxy) event.getThrowableProxy()).getThrowable();
}
if (throwable != null) {
MessageUtils.sendException(msg, throwable, FlareBot.getInstance().getUpdateChannel());
} else MessageUtils.sendMessage(msg, FlareBot.getInstance().getUpdateChannel());
});
}
return FilterReply.NEUTRAL;
}
示例10: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(E eventObject) {
if (!isStarted()) {
return FilterReply.NEUTRAL;
}
LoggingEvent event = (LoggingEvent) eventObject;
if (this.levelMin != null && !event.getLevel().isGreaterOrEqual(levelMin)) {
return DENY;
}
if (this.levelMax != null && event.getLevel().toInt() > levelMax.toInt()) {
return DENY;
}
if (acceptOnMatch) {
return ACCEPT;
} else {
return NEUTRAL;
}
}
示例11: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
@Override
public FilterReply decide(final ILoggingEvent event) {
String marker = MDC.get(MDC_MARKER_ID);
if (MDC.get(TASK_LOG_WITH_PROGRESS_MDC) != null && INTERNAL_PROGRESS.getName().equals(marker)) {
// internal progress logs for TaskLogType.TASK_LOG_WITH_PROGRESS are wanted
return NEUTRAL;
}
if (PROGRESS.getName().equals(marker) || TASK_LOG_ONLY.getName().equals(marker) ||
MDC.get(TASK_LOG_ONLY_MDC) != null) {
return DENY;
}
return NEUTRAL;
}
示例12: decide
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
public FilterReply decide(E event) {
// let us not throw an exception
// see also bug #17.
if (!isStarted() || !evaluator.isStarted()) {
return FilterReply.NEUTRAL;
}
try {
if (evaluator.evaluate(event)) {
return onMatch;
} else {
return onMismatch;
}
} catch (EvaluationException e) {
addError("Evaluator " + evaluator.getName() + " threw an exception", e);
return FilterReply.NEUTRAL;
}
}
示例13: filterAndLog_0_Or3Plus
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
/**
* The next methods are not merged into one because of the time we gain by not
* creating a new Object[] with the params. This reduces the cost of not
* logging by about 20 nanoseconds.
*/
private void filterAndLog_0_Or3Plus(final String localFQCN,
final Marker marker, final Level level, final String msg,
final Object[] params, final Throwable t) {
final FilterReply decision = loggerContext
.getTurboFilterChainDecision_0_3OrMore(marker, this, level, msg,
params, t);
if (decision == FilterReply.NEUTRAL) {
if (effectiveLevelInt > level.levelInt) {
return;
}
} else if (decision == FilterReply.DENY) {
return;
}
buildLoggingEventAndAppend(localFQCN, marker, level, msg, params, t);
}
示例14: filterAndLog_1
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
private void filterAndLog_1(final String localFQCN,
final Marker marker, final Level level, final String msg,
final Object param, final Throwable t) {
final FilterReply decision = loggerContext.getTurboFilterChainDecision_1(
marker, this, level, msg, param, t);
if (decision == FilterReply.NEUTRAL) {
if (effectiveLevelInt > level.levelInt) {
return;
}
} else if (decision == FilterReply.DENY) {
return;
}
buildLoggingEventAndAppend(localFQCN, marker, level, msg,
new Object[] { param }, t);
}
示例15: filterAndLog_2
import ch.qos.logback.core.spi.FilterReply; //导入依赖的package包/类
private void filterAndLog_2(final String localFQCN,
final Marker marker, final Level level, final String msg,
final Object param1, final Object param2, final Throwable t) {
final FilterReply decision = loggerContext.getTurboFilterChainDecision_2(
marker, this, level, msg, param1, param2, t);
if (decision == FilterReply.NEUTRAL) {
if (effectiveLevelInt > level.levelInt) {
return;
}
} else if (decision == FilterReply.DENY) {
return;
}
buildLoggingEventAndAppend(localFQCN, marker, level, msg, new Object[] {
param1, param2 }, t);
}