當前位置: 首頁>>代碼示例>>Java>>正文


Java Filter.ACCEPT屬性代碼示例

本文整理匯總了Java中org.apache.log4j.spi.Filter.ACCEPT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Filter.ACCEPT屬性的具體用法?Java Filter.ACCEPT怎麽用?Java Filter.ACCEPT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.log4j.spi.Filter的用法示例。


在下文中一共展示了Filter.ACCEPT屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doAppend

/**
 * 覆寫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);
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:27,代碼來源:KafkaAppender.java

示例2: doAppend

/**
  * 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);    
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:30,代碼來源:AppenderSkeleton.java

示例3: decide

/**
   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;
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:31,代碼來源:LevelMatchFilter.java

示例4: decide

/**
    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;
     }
   }
 }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:21,代碼來源:StringMatchFilter.java

示例5: doAppend

/**
  * 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.next;
    }
  }
  
  this.append(event);    
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:30,代碼來源:AppenderSkeleton.java

示例6: decide

public int decide(LoggingEvent event) {
	if (levelMin == null || event.getLevel().isGreaterOrEqual(levelMin))
		return Filter.NEUTRAL;

	String tn = event.getThreadName();

	if (tn == null || regex == null)
		return Filter.NEUTRAL;

	if (tn.matches(regex)) {
		if (getAcceptOnMatch()) {
			return Filter.ACCEPT;
		} else {
			return Filter.DENY;
		}
	} else {
		return Filter.NEUTRAL;
	}
}
 
開發者ID:ibissource,項目名稱:iaf,代碼行數:19,代碼來源:IbisThreadFilter.java

示例7: addLog4jFileAppender

Path addLog4jFileAppender(final Path path) throws IOException {
    org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();

    String pattern = "%d{HH:mm:ss.SSS} %-5p %t %C{1}.%M:%L - %m%n";
    final String threadName = Thread.currentThread().getName();

    class ThreadFilter extends Filter {
        @Override
        public int decide(LoggingEvent event) {
            if (event.getThreadName().startsWith(threadName)) {
                return Filter.ACCEPT;
            }
            return Filter.DENY;
        }
    }

    FileAppender fa = new FileAppender(new PatternLayout(pattern), path.toFile().getAbsolutePath());
    fa.addFilter(new ThreadFilter());
    fa.setThreshold(sysConfig.getCaseLogLevel());
    fa.setImmediateFlush(true);
    fa.setAppend(true);
    fa.setName(path.toFile().getAbsolutePath());

    fa.activateOptions();
    rootLogger.addAppender(fa);

    return path;
}
 
開發者ID:tascape,項目名稱:reactor,代碼行數:28,代碼來源:AbstractCaseRunner.java

示例8: decide

/**
   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;
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:32,代碼來源:LevelRangeFilter.java

示例9: decide

@Override
        public int decide(LoggingEvent le) {
            String mdc = (String) le.getMDC(KEY);
//        System.out.println("MDC: " + mdc);
//        System.out.println("key: " + _value);
            if (mdc.equals(_value)) {
                return Filter.ACCEPT;
            } else {
                return Filter.DENY;
            }
//        return Filter.ACCEPT;
        }
 
開發者ID:OpenJEVis,項目名稱:JECommons,代碼行數:12,代碼來源:DriverLoggerFactory.java

示例10: decide

@Override
public int decide(final LoggingEvent event) {
    final String thread = event.getThreadName();
    final int decision;
    if (thread.startsWith(VrbPrcMonitorFilter.THREADNAME_START
        + this.hash
    )) {
        decision = Filter.ACCEPT;
    } else {
        decision = Filter.DENY;
    }
    return decision;
}
 
開發者ID:jcabi,項目名稱:jcabi-log,代碼行數:13,代碼來源:VerboseProcessTest.java


注:本文中的org.apache.log4j.spi.Filter.ACCEPT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。