Java Code Examples for org.apache.logging.log4j.Level#isMoreSpecificThan()

The following examples show how to use org.apache.logging.log4j.Level#isMoreSpecificThan() . 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: HighlightErrorConverter.java    From TerminalConsoleAppender with MIT License 6 votes vote down vote up
@Override
public void format(LogEvent event, StringBuilder toAppendTo) {
    if (TerminalConsoleAppender.isAnsiSupported()) {
        Level level = event.getLevel();
        if (level.isMoreSpecificThan(Level.ERROR)) {
            format(ANSI_ERROR, event, toAppendTo);
            return;
        } else if (level.isMoreSpecificThan(Level.WARN)) {
            format(ANSI_WARN, event, toAppendTo);
            return;
        }
    }

    //noinspection ForLoopReplaceableByForEach
    for (int i = 0, size = formatters.size(); i < size; i++) {
        formatters.get(i).format(event, toAppendTo);
    }
}
 
Example 2
Source File: CatAppender4Log4j2.java    From x-pipe with Apache License 2.0 6 votes vote down vote up
@Override
public void append(LogEvent event) {
	
	MessageManager messageManager = Cat.getManager();
	
	boolean isTraceMode = false;
	if(messageManager != null){
		isTraceMode = messageManager.isTraceMode();
	}
	Level level = event.getLevel();

	if (level.isMoreSpecificThan(Level.ERROR)) {
		logError(event);
	} else if (isTraceMode) {
		logTrace(event);
	}

}
 
Example 3
Source File: DynamicThresholdFilter.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private Result filter(final Level level, final ReadOnlyStringMap contextMap) {
    final String value = contextMap.getValue(key);
    if (value != null) {
        Level ctxLevel = levelMap.get(value);
        if (ctxLevel == null) {
            ctxLevel = defaultThreshold;
        }
        return level.isMoreSpecificThan(ctxLevel) ? onMatch : onMismatch;
    }
    return Result.NEUTRAL;

}
 
Example 4
Source File: ThresholdFilter.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
private Result filter(final Level testLevel) {
    return testLevel.isMoreSpecificThan(this.level) ? onMatch : onMismatch;
}