Java Code Examples for org.apache.log4j.spi.Filter#DENY
The following examples show how to use
org.apache.log4j.spi.Filter#DENY .
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: KafkaAppender.java From SkyEye with GNU General Public License v3.0 | 6 votes |
/** * 覆写doAppend, 去掉closed的log日志 * @param event */ @Override public synchronized void doAppend(LoggingEvent event) { if (closed) { return; } if (!isAsSevereAsThreshold(event.getLevel())) { return; } Filter f = this.headFilter; FILTER_LOOP: while(f != null) { switch(f.decide(event)) { case Filter.DENY: return; case Filter.ACCEPT: break FILTER_LOOP; case Filter.NEUTRAL: f = f.getNext(); } } this.append(event); }
Example 2
Source File: AppenderSkeleton.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method performs threshold checks and invokes filters before * delegating actual logging to the subclasses specific {@link * AppenderSkeleton#append} method. * */ public synchronized void doAppend(LoggingEvent event) { if(closed) { LogLog.error("Attempted to append to closed appender named ["+name+"]."); return; } if(!isAsSevereAsThreshold(event.getLevel())) { return; } Filter f = this.headFilter; FILTER_LOOP: while(f != null) { switch(f.decide(event)) { case Filter.DENY: return; case Filter.ACCEPT: break FILTER_LOOP; case Filter.NEUTRAL: f = f.getNext(); } } this.append(event); }
Example 3
Source File: LevelMatchFilter.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** Return the decision of this filter. Returns {@link Filter#NEUTRAL} if the <b>LevelToMatch</b> option is not set or if there is not match. Otherwise, if there is a match, then the returned decision is {@link Filter#ACCEPT} if the <b>AcceptOnMatch</b> property is set to <code>true</code>. The returned decision is {@link Filter#DENY} if the <b>AcceptOnMatch</b> property is set to false. */ public int decide(LoggingEvent event) { if(this.levelToMatch == null) { return Filter.NEUTRAL; } boolean matchOccured = false; if(this.levelToMatch.equals(event.getLevel())) { matchOccured = true; } if(matchOccured) { if(this.acceptOnMatch) return Filter.ACCEPT; else return Filter.DENY; } else { return Filter.NEUTRAL; } }
Example 4
Source File: StringMatchFilter.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** Returns {@link Filter#NEUTRAL} is there is no string match. */ public int decide(LoggingEvent event) { String msg = event.getRenderedMessage(); if(msg == null || stringToMatch == null) return Filter.NEUTRAL; if( msg.indexOf(stringToMatch) == -1 ) { return Filter.NEUTRAL; } else { // we've got a match if(acceptOnMatch) { return Filter.ACCEPT; } else { return Filter.DENY; } } }
Example 5
Source File: FilterAdapter.java From logging-log4j2 with Apache License 2.0 | 6 votes |
@Override public Result filter(LogEvent event) { LoggingEvent loggingEvent = new LogEventAdapter(event); Filter next = filter; while (next != null) { switch (filter.decide(loggingEvent)) { case Filter.ACCEPT: return Result.ACCEPT; case Filter.DENY: return Result.DENY; default: } next = filter.getNext(); } return Result.NEUTRAL; }
Example 6
Source File: FilterAdapter.java From logging-log4j2 with Apache License 2.0 | 6 votes |
@Override public Result filter(LogEvent event) { LoggingEvent loggingEvent = new LogEventAdapter(event); Filter next = filter; while (next != null) { switch (filter.decide(loggingEvent)) { case Filter.ACCEPT: return Result.ACCEPT; case Filter.DENY: return Result.DENY; default: } next = filter.getNext(); } return Result.NEUTRAL; }
Example 7
Source File: LoggingTester.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public int decide(final LoggingEvent event) { int _xifexpression = (int) 0; String _loggerName = event.getLoggerName(); String _name = this.source.getName(); boolean _equals = Objects.equal(_loggerName, _name); if (_equals) { _xifexpression = Filter.DENY; } else { _xifexpression = Filter.NEUTRAL; } return _xifexpression; }
Example 8
Source File: LoggingTester.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public int decide(final LoggingEvent event) { int _xifexpression = (int) 0; String _loggerName = event.getLoggerName(); String _name = this.source.getName(); boolean _equals = Objects.equal(_loggerName, _name); if (_equals) { _xifexpression = Filter.DENY; } else { _xifexpression = Filter.NEUTRAL; } return _xifexpression; }
Example 9
Source File: LevelRangeFilter.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** Return the decision of this filter. */ public int decide(LoggingEvent event) { if(this.levelMin != null) { if (event.getLevel().isGreaterOrEqual(levelMin) == false) { // level of event is less than minimum return Filter.DENY; } } if(this.levelMax != null) { if (event.getLevel().toInt() > levelMax.toInt()) { // level of event is greater than maximum // Alas, there is no Level.isGreater method. and using // a combo of isGreaterOrEqual && !Equal seems worse than // checking the int values of the level objects.. return Filter.DENY; } } if (acceptOnMatch) { // this filter set up to bypass later filters and always return // accept if level in range return Filter.ACCEPT; } else { // event is ok for this filter; allow later filters to have a look.. return Filter.NEUTRAL; } }
Example 10
Source File: PrimitiveAuthorityProxy.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
@Override public int decide(LoggingEvent event) { Object oRunId = event.getMDC(LogUtils.MDC_RUNID_KEY); if (!(oRunId instanceof Long)) return Filter.DENY; Long rId = (Long)oRunId; if (this.runId != rId.longValue()) return Filter.DENY; else { if (event.getLevel().isGreaterOrEqual(logLevel)) return Filter.ACCEPT; else return Filter.DENY; } }
Example 11
Source File: DenyAllFilter.java From cacheonix-core with GNU Lesser General Public License v2.1 | 2 votes |
/** Always returns the integer constant {@link Filter#DENY} regardless of the {@link LoggingEvent} parameter. @param event The LoggingEvent to filter. @return Always returns {@link Filter#DENY}. */ public int decide(LoggingEvent event) { return Filter.DENY; }