CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-slf4j--log4j-over-slf4j

Log4j 1.x API compatibility layer that implements Apache Log4j API over SLF4J for seamless migration

Pending
Overview
Eval results
Files

level-management.mddocs/

Level Management

Level and priority system providing standard Log4j levels with conversion utilities and level comparison methods. The Level class extends Priority and provides the standard logging level hierarchy.

Capabilities

Standard Levels

Pre-defined level constants representing the standard Log4j logging hierarchy.

/**
 * Turn off all logging
 */
public static final Level OFF;

/**
 * Very severe error events that will presumably lead the application to abort
 */
public static final Level FATAL;

/**
 * Error events that might still allow the application to continue running
 */
public static final Level ERROR;

/**
 * Potentially harmful situations
 */
public static final Level WARN;

/**
 * Informational messages that highlight the progress of the application
 */
public static final Level INFO;

/**
 * Fine-grained informational events for debugging
 */
public static final Level DEBUG;

/**
 * Finer-grained informational events than DEBUG
 */
public static final Level TRACE;

/**
 * Turn on all logging
 */
public static final Level ALL;

Level Integer Constants:

// Level integer values for comparison
public static final int TRACE_INT = 5000;
public static final int X_TRACE_INT = DEBUG_INT - 100; // 9900 - Extended trace level
public static final int DEBUG_INT = 10000;
public static final int INFO_INT = 20000;
public static final int WARN_INT = 30000;  
public static final int ERROR_INT = 40000;
public static final int FATAL_INT = 50000;
public static final int OFF_INT = Integer.MAX_VALUE;
public static final int ALL_INT = Integer.MIN_VALUE;

Usage Examples:

import org.apache.log4j.Level;

// Use predefined levels
Level debugLevel = Level.DEBUG;
Level infoLevel = Level.INFO;
Level errorLevel = Level.ERROR;

// Compare levels
boolean isDebugHigher = Level.DEBUG.isGreaterOrEqual(Level.TRACE); // true
boolean isInfoLower = Level.INFO.isGreaterOrEqual(Level.ERROR); // false

Level Conversion

Methods to convert strings and integers to Level instances with optional defaults.

/**
 * Convert string to level, defaults to DEBUG if conversion fails
 * @param sArg String representation of level
 * @return Corresponding Level
 */
public static Level toLevel(String sArg);

/**
 * Convert string to level with custom default
 * @param sArg String representation of level
 * @param defaultLevel Default level if conversion fails
 * @return Corresponding Level
 */
public static Level toLevel(String sArg, Level defaultLevel);

/**
 * Convert integer to level, defaults to DEBUG if conversion fails
 * @param val Integer representation of level
 * @return Corresponding Level
 */
public static Level toLevel(int val);

/**
 * Convert integer to level with custom default
 * @param val Integer representation of level
 * @param defaultLevel Default level if conversion fails
 * @return Corresponding Level
 */
public static Level toLevel(int val, Level defaultLevel);

Usage Examples:

// String conversion
Level level1 = Level.toLevel("INFO"); // Level.INFO
Level level2 = Level.toLevel("INVALID"); // Level.DEBUG (default)
Level level3 = Level.toLevel("INVALID", Level.WARN); // Level.WARN (custom default)

// Integer conversion
Level level4 = Level.toLevel(20000); // Level.INFO
Level level5 = Level.toLevel(99999); // Level.DEBUG (default)
Level level6 = Level.toLevel(99999, Level.ERROR); // Level.ERROR (custom default)

// Case insensitive
Level level7 = Level.toLevel("debug"); // Level.DEBUG
Level level8 = Level.toLevel("WaRn"); // Level.WARN

Priority Base Class

Base Priority class providing core level functionality (deprecated, use Level instead).

/**
 * Priority class (deprecated - use Level instead)
 */
public class Priority {
    /**
     * Integer representation of priority level
     */
    transient int level;
    
    /**
     * String representation of priority level
     */
    transient String levelStr;
    
    /**
     * Syslog equivalent integer
     */
    transient int syslogEquivalent;
    
    /**
     * Compare priorities for equality
     * @param o Object to compare
     * @return true if equal priority levels
     */
    public boolean equals(Object o);
    
    /**
     * Check if this priority is greater than or equal to another
     * @param r Priority to compare against
     * @return true if this priority >= r
     */
    public boolean isGreaterOrEqual(Priority r);
    
    /**
     * Get syslog equivalent value
     * @return Syslog equivalent integer
     */
    public final int getSyslogEquivalent();
    
    /**
     * Get integer representation
     * @return Priority level as integer
     */
    public final int toInt();
    
    /**
     * Get string representation
     * @return Priority level as string
     */
    public final String toString();
}

Usage Examples:

// Priority comparison (though Level should be used instead)
Priority p1 = Level.INFO;
Priority p2 = Level.DEBUG;

boolean isGreater = p1.isGreaterOrEqual(p2); // true (INFO > DEBUG)
boolean areEqual = p1.equals(Level.INFO); // true

// Get representations
int intValue = p1.toInt(); // 20000
String stringValue = p1.toString(); // "INFO"
int syslogEquiv = p1.getSyslogEquivalent(); // 6

Deprecated Priority Constants

Legacy Priority constants (deprecated - use Level equivalents instead).

/**
 * @deprecated Use Level.FATAL instead
 */
@Deprecated
public static final Priority FATAL;

/**
 * @deprecated Use Level.ERROR instead  
 */
@Deprecated
public static final Priority ERROR;

/**
 * @deprecated Use Level.WARN instead
 */
@Deprecated
public static final Priority WARN;

/**
 * @deprecated Use Level.INFO instead
 */
@Deprecated
public static final Priority INFO;

/**
 * @deprecated Use Level.DEBUG instead
 */
@Deprecated
public static final Priority DEBUG;

Deprecated Priority Conversion

Legacy Priority conversion methods (deprecated - use Level.toLevel() instead).

/**
 * @deprecated Use Level.toLevel(String) instead
 * @param sArg String to convert
 * @return Corresponding Priority
 */
@Deprecated
public static Priority toPriority(String sArg);

/**
 * @deprecated Use Level.toLevel(int) instead
 * @param val Integer to convert
 * @return Corresponding Priority
 */
@Deprecated
public static Priority toPriority(int val);

/**
 * @deprecated Use Level.toLevel(String, Level) instead
 * @param sArg String to convert
 * @param defaultPriority Default if conversion fails
 * @return Corresponding Priority
 */
@Deprecated
public static Priority toPriority(String sArg, Priority defaultPriority);

/**
 * @deprecated Use Level.toLevel(int, Level) instead
 * @param val Integer to convert
 * @param defaultPriority Default if conversion fails
 * @return Corresponding Priority
 */
@Deprecated
public static Priority toPriority(int val, Priority defaultPriority);

/**
 * Get all possible priorities as array (deprecated)
 * @return Array of all Priority instances
 * @deprecated This method will be removed with no replacement
 */
@Deprecated
public static Priority[] getAllPossiblePriorities();

Migration Examples:

// Old (deprecated)
Priority oldLevel = Priority.toPriority("INFO");

// New (recommended)
Level newLevel = Level.toLevel("INFO");

// Old conversion with default
Priority oldDefault = Priority.toPriority("INVALID", Priority.WARN);

// New conversion with default
Level newDefault = Level.toLevel("INVALID", Level.WARN);

Install with Tessl CLI

npx tessl i tessl/maven-org-slf4j--log4j-over-slf4j

docs

appenders-layouts.md

configuration.md

core-logging.md

diagnostic-contexts.md

index.md

level-management.md

tile.json