CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-ch-qos-logback--logback-classic

Comprehensive SLF4J implementation providing enterprise-grade logging with flexible configuration, high performance, and extensive appender ecosystem for Java applications.

Pending
Overview
Eval results
Files

core-logging.mddocs/

Core Logging

Essential logging functionality including the Logger interface, logging contexts, level management, and the foundational components of the Logback Classic logging system.

Capabilities

Logger Interface

The main logging facade implementing the SLF4J Logger interface with Logback-specific extensions.

/**
 * Main logger interface implementing SLF4J Logger with Logback extensions
 */
public final class Logger implements org.slf4j.Logger, LocationAwareLogger, AppenderAttachable<ILoggingEvent> {
    // Constants
    public static final String FQCN = "ch.qos.logback.classic.Logger";
    // ROOT_LOGGER_NAME is inherited from org.slf4j.Logger interface
    
    // Basic logging methods
    public void trace(String msg);
    public void debug(String msg);
    public void info(String msg);
    public void warn(String msg);
    public void error(String msg);
    
    // Parameterized logging
    public void trace(String format, Object arg);
    public void trace(String format, Object arg1, Object arg2);
    public void trace(String format, Object... arguments);
    
    public void debug(String format, Object arg);
    public void debug(String format, Object arg1, Object arg2);
    public void debug(String format, Object... arguments);
    
    public void info(String format, Object arg);
    public void info(String format, Object arg1, Object arg2);
    public void info(String format, Object... arguments);
    
    public void warn(String format, Object arg);
    public void warn(String format, Object arg1, Object arg2);
    public void warn(String format, Object... arguments);
    
    public void error(String format, Object arg);
    public void error(String format, Object arg1, Object arg2);
    public void error(String format, Object... arguments);
    
    // Exception logging
    public void trace(String msg, Throwable t);
    public void debug(String msg, Throwable t);
    public void info(String msg, Throwable t);
    public void warn(String msg, Throwable t);
    public void error(String msg, Throwable t);
    
    // Marker-based logging
    public void trace(Marker marker, String msg);
    public void debug(Marker marker, String msg);
    public void info(Marker marker, String msg);
    public void warn(Marker marker, String msg);
    public void error(Marker marker, String msg);
    
    // Level checking
    public boolean isTraceEnabled();
    public boolean isDebugEnabled();
    public boolean isInfoEnabled();
    public boolean isWarnEnabled();
    public boolean isErrorEnabled();
    
    // Logback-specific methods
    public Level getLevel();
    public void setLevel(Level level);
    public Level getEffectiveLevel();
    public boolean isEnabledFor(Level level);
    
    // Appender management
    public void addAppender(Appender<ILoggingEvent> newAppender);
    public boolean detachAppender(Appender<ILoggingEvent> appender);
    public boolean detachAppender(String name);
    public void detachAndStopAllAppenders();
    
    // Hierarchy management
    public LoggerContext getLoggerContext();
    public String getName();
    public Logger getParent();
    public void setParent(Logger parent);
    public boolean getAdditivity();
    public void setAdditivity(boolean additivity);
}

Usage Examples:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class UserService {
    private static final Logger logger = LoggerFactory.getLogger(UserService.class);
    
    public User createUser(String username, String email) {
        logger.info("Creating user: username={}, email={}", username, email);
        
        try {
            User user = new User(username, email);
            logger.debug("User object created: {}", user);
            return user;
        } catch (Exception e) {
            logger.error("Failed to create user: username={}", username, e);
            throw e;
        }
    }
}

LoggerContext

Central registry and factory for Logger instances, managing the logger hierarchy and system-wide configuration.

/**
 * Central logger context managing the logger hierarchy and system configuration
 */
public class LoggerContext extends ContextBase implements ILoggerFactory, LifeCycle {
    // Constants
    public static final boolean DEFAULT_PACKAGING_DATA = false;
    
    // Logger management
    public Logger getLogger(String name);
    public Logger getLogger(Class<?> clazz);
    public Logger exists(String name);
    public List<Logger> getLoggerList();
    
    // Lifecycle management
    public void start();
    public void stop();
    public boolean isStarted();
    
    // Configuration
    public void reset();
    public void setPackagingDataEnabled(boolean packagingDataEnabled);
    public boolean isPackagingDataEnabled();
    public void setMaxCallerDataDepth(int maxCallerDataDepth);
    public int getMaxCallerDataDepth();
    
    // Turbo filters
    public void addTurboFilter(TurboFilter newFilter);
    public void resetTurboFilterList();
    public List<TurboFilter> getTurboFilterList();
    
    // Context properties
    public void putProperty(String key, String val);
    public String getProperty(String key);
    public Map<String, String> getCopyOfPropertyMap();
    
    // Listeners
    public void addListener(LoggerContextListener listener);
    public void removeListener(LoggerContextListener listener);
    
    // Status and metadata
    public LoggerContextVO getLoggerContextRemoteView();
    public String getName();
    public void setName(String name);
    public long getBirthTime();
    public Object getConfigurationLock();
}

Usage Examples:

import ch.qos.logback.classic.LoggerContext;
import org.slf4j.LoggerFactory;

// Get the logger context
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

// Configure context properties
context.putProperty("app.name", "MyApplication");
context.putProperty("app.version", "1.0.0");

// Reset configuration
context.reset();

// Enable packaging data for stack traces
context.setPackagingDataEnabled(true);

Level

Defines the hierarchy of logging levels with integer values for comparison and filtering.

/**
 * Defines logging levels with integer values for efficient comparison
 */
public final class Level implements Serializable {
    // Level integer constants
    public static final int OFF_INT = Integer.MAX_VALUE;
    public static final int ERROR_INT = 40000;
    public static final int WARN_INT = 30000;
    public static final int INFO_INT = 20000;
    public static final int DEBUG_INT = 10000;
    public static final int TRACE_INT = 5000;
    public static final int ALL_INT = Integer.MIN_VALUE;
    
    // Integer wrapper constants
    public static final Integer OFF_INTEGER = OFF_INT;
    public static final Integer ERROR_INTEGER = ERROR_INT;
    public static final Integer WARN_INTEGER = WARN_INT;
    public static final Integer INFO_INTEGER = INFO_INT;
    public static final Integer DEBUG_INTEGER = DEBUG_INT;
    public static final Integer TRACE_INTEGER = TRACE_INT;
    public static final Integer ALL_INTEGER = ALL_INT;
    
    // Level instances
    public static final Level OFF = new Level(OFF_INT, "OFF");
    public static final Level ERROR = new Level(ERROR_INT, "ERROR");
    public static final Level WARN = new Level(WARN_INT, "WARN");
    public static final Level INFO = new Level(INFO_INT, "INFO");
    public static final Level DEBUG = new Level(DEBUG_INT, "DEBUG");
    public static final Level TRACE = new Level(TRACE_INT, "TRACE");
    /** @deprecated with no replacement - use TRACE level instead */
    public static final Level ALL = new Level(ALL_INT, "ALL");
    
    // Level operations
    public String toString();
    public int toInt();
    public boolean isGreaterOrEqual(Level r);
    public static Level toLevel(String sArg);
    public static Level toLevel(int val);
    public static Level valueOf(String sArg);
}

Usage Examples:

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.Level;

// Set logger level programmatically
Logger logger = (Logger) LoggerFactory.getLogger("com.example");
logger.setLevel(Level.DEBUG);

// Check effective level
Level effectiveLevel = logger.getEffectiveLevel();
System.out.println("Effective level: " + effectiveLevel);

// Level comparison
if (Level.INFO.isGreaterOrEqual(Level.DEBUG)) {
    System.out.println("INFO is greater than or equal to DEBUG");
}

Logging Events

Core interfaces and classes representing individual logging events.

/**
 * Central interface representing a logging event
 */
public interface ILoggingEvent extends DeferredProcessingAware {
    String getThreadName();
    Level getLevel();
    String getMessage();
    Object[] getArgumentArray();
    String getFormattedMessage();
    String getLoggerName();
    LoggerContextVO getLoggerContextVO();
    IThrowableProxy getThrowableProxy();
    StackTraceElement[] getCallerData();
    boolean hasCallerData();
    /** @deprecated Replaced by getMarkerList() */
    Marker getMarker();
    List<Marker> getMarkerList();
    Map<String, String> getMDCPropertyMap();
    /** @deprecated Replaced by getMDCPropertyMap() */
    Map<String, String> getMdc();
    long getTimeStamp();
    int getNanoseconds();
    long getSequenceNumber();
    List<KeyValuePair> getKeyValuePairs();
    Instant getInstant();
    void prepareForDeferredProcessing();
}

/**
 * Default implementation of ILoggingEvent
 */
public class LoggingEvent implements ILoggingEvent {
    // Constructors
    public LoggingEvent();
    public LoggingEvent(String fqcn, Logger logger, Level level, String message, Throwable throwable, Object[] argArray);
    
    // All ILoggingEvent methods implemented
    // Plus additional utility methods for event creation and manipulation
}

/**
 * Interface for exception information in logging events
 */
public interface IThrowableProxy {
    String getMessage();
    String getClassName();
    StackTraceElementProxy[] getStackTraceElementProxyArray();
    int getCommonFrames();
    IThrowableProxy getCause();
    IThrowableProxy[] getSuppressed();
    String getCycledCauseTrace();
    boolean isCyclic();
}

Constants and Utilities

/**
 * Constants used throughout Logback Classic
 */
public class ClassicConstants {
    // Configuration properties
    public static final String LOGBACK_CONTEXT_SELECTOR = "logback.ContextSelector";
    public static final String CONFIG_FILE_PROPERTY = "logback.configurationFile";
    public static final String MODEL_CONFIG_FILE_PROPERTY = "logback.scmoFile";
    
    // Default configuration files
    public static final String AUTOCONFIG_FILE = "logback.xml";
    public static final String TEST_AUTOCONFIG_FILE = "logback-test.xml";
    
    // System properties
    public static final int DEFAULT_MAX_CALLEDER_DATA_DEPTH = 8;
    public static final String USER_MDC_KEY = "user";
    
    // Request-related MDC keys
    public static final String REQUEST_REMOTE_HOST_MDC_KEY = "req.remoteHost";
    public static final String REQUEST_USER_AGENT_MDC_KEY = "req.userAgent";
    public static final String REQUEST_REQUEST_URI = "req.requestURI";
    public static final String REQUEST_QUERY_STRING = "req.queryString";
    public static final String REQUEST_REQUEST_URL = "req.requestURL";
    public static final String REQUEST_METHOD = "req.method";
    public static final String REQUEST_X_FORWARDED_FOR = "req.xForwardedFor";
}

Install with Tessl CLI

npx tessl i tessl/maven-ch-qos-logback--logback-classic

docs

appenders.md

configuration.md

core-logging.md

encoders-layouts.md

filters.md

index.md

network-logging.md

servlet-integration.md

tile.json