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
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

Logback Classic

Logback Classic is a comprehensive logging library for Java that provides a complete implementation of the SLF4J API. As the successor to Log4j, it offers enterprise-grade logging with flexible configuration, high performance, and extensive features for production environments.

Package Information

  • Package Name: ch.qos.logback:logback-classic
  • Package Type: maven
  • Language: Java
  • Installation: implementation 'ch.qos.logback:logback-classic:1.5.18' (Gradle) or <dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.5.18</version></dependency> (Maven)

Core Imports

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

For SLF4J facade usage (recommended):

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

Basic Usage

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

public class Application {
    private static final Logger logger = LoggerFactory.getLogger(Application.class);
    
    public static void main(String[] args) {
        logger.info("Application starting");
        logger.warn("This is a warning message");
        logger.error("Error occurred: {}", "sample error", new RuntimeException("test"));
        
        // With structured logging
        logger.info("User action: user={}, action={}", "alice", "login");
    }
}

Architecture

Logback Classic is built around several key components:

  • Logger Hierarchy: Tree-structured logger organization with inheritance
  • Appenders: Output destinations (console, file, network, email, etc.)
  • Encoders & Layouts: Message formatting and encoding
  • Filters: Event filtering at multiple levels (context, logger, appender)
  • Configuration System: XML, Groovy, and programmatic configuration
  • SPI Integration: Extensible service provider interfaces

Capabilities

Core Logging

Essential logging functionality including the Logger interface, logging contexts, and level management.

// Main logger interface (via SLF4J)
public interface Logger {
    void trace(String msg);
    void debug(String msg);
    void info(String msg);
    void warn(String msg);
    void error(String msg);
    
    // Parameterized messages
    void info(String format, Object... arguments);
    void error(String msg, Throwable t);
}

// Logback-specific Logger class
public final class Logger implements org.slf4j.Logger {
    public static final String FQCN = "ch.qos.logback.classic.Logger";
    // ROOT_LOGGER_NAME is inherited from org.slf4j.Logger interface
}

// Logger factory and context
public class LoggerContext implements ILoggerFactory {
    public Logger getLogger(String name);
    public void reset();
    public void stop();
}

// Logging levels
public final class Level {
    public static final Level OFF;
    public static final Level ERROR;
    public static final Level WARN;
    public static final Level INFO;
    public static final Level DEBUG;
    public static final Level TRACE;
    public static final Level ALL;
}

Core Logging

Configuration

Programmatic and XML-based configuration for loggers, appenders, and overall system behavior.

public class BasicConfigurator {
    public static void configure(LoggerContext lc);
}

public interface Configurator {
    enum ExecutionStatus { NEUTRAL, INVOKE_NEXT_IF_ANY, DO_NOT_INVOKE_NEXT_IF_ANY }
    ExecutionStatus configure(LoggerContext context);
}

Configuration

Appenders

Output destinations for log events including console, file, network, and specialized appenders.

public class AsyncAppender extends AsyncAppenderBase<ILoggingEvent> {
    // High-performance asynchronous logging
}

// Key appender interfaces
public interface Appender<E> {
    void doAppend(E event);
    String getName();
    void setName(String name);
}

Appenders

Encoders and Layouts

Message formatting and encoding for different output formats and protocols.

public class PatternLayout extends LayoutBase<ILoggingEvent> {
    // Pattern-based message formatting
}

public class PatternLayoutEncoder extends EncoderBase<ILoggingEvent> {
    // Encoder using PatternLayout
}

public class JsonEncoder extends EncoderBase<ILoggingEvent> {
    // JSON-based structured logging
}

Encoders and Layouts

Filters

Event filtering mechanisms for controlling which log events are processed.

public class LevelFilter extends Filter<ILoggingEvent> {
    // Filter based on log level
}

public class ThresholdFilter extends Filter<ILoggingEvent> {
    // Filter based on minimum threshold
}

public abstract class TurboFilter extends ContextAwareBase {
    // High-performance filtering
}

Filters

Network Logging

Remote logging capabilities including socket appenders, receivers, and email alerts.

public class SocketAppender extends AppenderBase<ILoggingEvent> {
    // TCP socket-based remote logging
}

public class SMTPAppender extends SMTPAppenderBase<ILoggingEvent> {
    // Email-based alert system
}

public class SyslogAppender extends AppenderBase<ILoggingEvent> {
    // Syslog protocol support
}

Network Logging

Servlet Integration

Web application integration components for servlet containers.

public class LogbackServletContextListener implements ServletContextListener {
    // Servlet container lifecycle integration
}

public class LogbackServletContainerInitializer implements ServletContainerInitializer {
    // Automatic servlet container setup
}

Servlet Integration

Types

// Core logging event interface
public interface ILoggingEvent {
    String getThreadName();
    Level getLevel();
    String getMessage();
    Object[] getArgumentArray();
    String getFormattedMessage();
    String getLoggerName();
    IThrowableProxy getThrowableProxy();
    long getTimeStamp();
    Map<String, String> getMDCPropertyMap();
    Marker getMarker();
}

// Exception handling
public interface IThrowableProxy {
    String getMessage();
    String getClassName();
    StackTraceElementProxy[] getStackTraceElementProxyArray();
    IThrowableProxy getCause();
}

// Context information
public class LoggerContextVO {
    String getName();
    Map<String, String> getPropertyMap();
    long getBirthTime();
}

docs

appenders.md

configuration.md

core-logging.md

encoders-layouts.md

filters.md

index.md

network-logging.md

servlet-integration.md

tile.json