本文整理匯總了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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}