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

The following examples show how to use org.apache.logging.log4j.Level#equals() . 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: PythonProcess.java    From modernmt with Apache License 2.0 5 votes vote down vote up
public static String getNativeLogLevel() {
    Logger logger = LogManager.getLogger(PythonProcess.class);
    Level level = logger.getLevel();

    for (Map.Entry<String, Level> entry : LOG_LEVELS.entrySet()) {
        if (level.equals(entry.getValue()))
            return entry.getKey().toLowerCase();
    }

    return null;
}
 
Example 2
Source File: SimpleControllerIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
private Condition<LogEvent> eventContains(String substring, Level level) {

        return new Condition<LogEvent>(entry -> (substring == null || (entry.getMessage()
            .getFormattedMessage() != null && entry.getMessage()
                .getFormattedMessage()
                .contains(substring)))
            && (level == null || level.equals(entry.getLevel())), String.format("entry with message '%s', level %s", substring, level));
    }
 
Example 3
Source File: Log4j2LoggingHelper.java    From herd with Apache License 2.0 4 votes vote down vote up
/**
 * Converts a Log4J specific log level to a generic log level.
 *
 * @param level the Log4J log level.
 *
 * @return the generic log level.
 */
private LogLevel log4jToGenericLogLevel(Level level)
{
    LogLevel logLevel = LogLevel.ALL;
    if (level.equals(Level.OFF))
    {
        logLevel = LogLevel.OFF;
    }
    else if (level.equals(Level.FATAL))
    {
        logLevel = LogLevel.FATAL;
    }
    else if (level.equals(Level.ERROR))
    {
        logLevel = LogLevel.ERROR;
    }
    else if (level.equals(Level.WARN))
    {
        logLevel = LogLevel.WARN;
    }
    else if (level.equals(Level.INFO))
    {
        logLevel = LogLevel.INFO;
    }
    else if (level.equals(Level.DEBUG))
    {
        logLevel = LogLevel.DEBUG;
    }
    else if (level.equals(Level.TRACE))
    {
        logLevel = LogLevel.TRACE;
    }
    else if (level.equals(Level.ALL))
    {
        logLevel = LogLevel.ALL;
    }
    else
    {
        LOGGER.warn("Unsupported log level encountered: " + level.toString() + ". Using ALL.");
    }
    return logLevel;
}