or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/ch.qos.logback/logback-classic@1.5.x

To install, run

npx @tessl/cli install tessl/maven-ch-qos-logback--logback-classic@1.5.0

0

# Logback Classic

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: ch.qos.logback:logback-classic

7

- **Package Type**: maven

8

- **Language**: Java

9

- **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)

10

11

## Core Imports

12

13

```java

14

import ch.qos.logback.classic.Logger;

15

import ch.qos.logback.classic.LoggerContext;

16

import ch.qos.logback.classic.Level;

17

import org.slf4j.LoggerFactory;

18

```

19

20

For SLF4J facade usage (recommended):

21

22

```java

23

import org.slf4j.Logger;

24

import org.slf4j.LoggerFactory;

25

```

26

27

## Basic Usage

28

29

```java

30

import org.slf4j.Logger;

31

import org.slf4j.LoggerFactory;

32

33

public class Application {

34

private static final Logger logger = LoggerFactory.getLogger(Application.class);

35

36

public static void main(String[] args) {

37

logger.info("Application starting");

38

logger.warn("This is a warning message");

39

logger.error("Error occurred: {}", "sample error", new RuntimeException("test"));

40

41

// With structured logging

42

logger.info("User action: user={}, action={}", "alice", "login");

43

}

44

}

45

```

46

47

## Architecture

48

49

Logback Classic is built around several key components:

50

51

- **Logger Hierarchy**: Tree-structured logger organization with inheritance

52

- **Appenders**: Output destinations (console, file, network, email, etc.)

53

- **Encoders & Layouts**: Message formatting and encoding

54

- **Filters**: Event filtering at multiple levels (context, logger, appender)

55

- **Configuration System**: XML, Groovy, and programmatic configuration

56

- **SPI Integration**: Extensible service provider interfaces

57

58

## Capabilities

59

60

### Core Logging

61

62

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

63

64

```java { .api }

65

// Main logger interface (via SLF4J)

66

public interface Logger {

67

void trace(String msg);

68

void debug(String msg);

69

void info(String msg);

70

void warn(String msg);

71

void error(String msg);

72

73

// Parameterized messages

74

void info(String format, Object... arguments);

75

void error(String msg, Throwable t);

76

}

77

78

// Logback-specific Logger class

79

public final class Logger implements org.slf4j.Logger {

80

public static final String FQCN = "ch.qos.logback.classic.Logger";

81

// ROOT_LOGGER_NAME is inherited from org.slf4j.Logger interface

82

}

83

84

// Logger factory and context

85

public class LoggerContext implements ILoggerFactory {

86

public Logger getLogger(String name);

87

public void reset();

88

public void stop();

89

}

90

91

// Logging levels

92

public final class Level {

93

public static final Level OFF;

94

public static final Level ERROR;

95

public static final Level WARN;

96

public static final Level INFO;

97

public static final Level DEBUG;

98

public static final Level TRACE;

99

public static final Level ALL;

100

}

101

```

102

103

[Core Logging](./core-logging.md)

104

105

### Configuration

106

107

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

108

109

```java { .api }

110

public class BasicConfigurator {

111

public static void configure(LoggerContext lc);

112

}

113

114

public interface Configurator {

115

enum ExecutionStatus { NEUTRAL, INVOKE_NEXT_IF_ANY, DO_NOT_INVOKE_NEXT_IF_ANY }

116

ExecutionStatus configure(LoggerContext context);

117

}

118

```

119

120

[Configuration](./configuration.md)

121

122

### Appenders

123

124

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

125

126

```java { .api }

127

public class AsyncAppender extends AsyncAppenderBase<ILoggingEvent> {

128

// High-performance asynchronous logging

129

}

130

131

// Key appender interfaces

132

public interface Appender<E> {

133

void doAppend(E event);

134

String getName();

135

void setName(String name);

136

}

137

```

138

139

[Appenders](./appenders.md)

140

141

### Encoders and Layouts

142

143

Message formatting and encoding for different output formats and protocols.

144

145

```java { .api }

146

public class PatternLayout extends LayoutBase<ILoggingEvent> {

147

// Pattern-based message formatting

148

}

149

150

public class PatternLayoutEncoder extends EncoderBase<ILoggingEvent> {

151

// Encoder using PatternLayout

152

}

153

154

public class JsonEncoder extends EncoderBase<ILoggingEvent> {

155

// JSON-based structured logging

156

}

157

```

158

159

[Encoders and Layouts](./encoders-layouts.md)

160

161

### Filters

162

163

Event filtering mechanisms for controlling which log events are processed.

164

165

```java { .api }

166

public class LevelFilter extends Filter<ILoggingEvent> {

167

// Filter based on log level

168

}

169

170

public class ThresholdFilter extends Filter<ILoggingEvent> {

171

// Filter based on minimum threshold

172

}

173

174

public abstract class TurboFilter extends ContextAwareBase {

175

// High-performance filtering

176

}

177

```

178

179

[Filters](./filters.md)

180

181

### Network Logging

182

183

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

184

185

```java { .api }

186

public class SocketAppender extends AppenderBase<ILoggingEvent> {

187

// TCP socket-based remote logging

188

}

189

190

public class SMTPAppender extends SMTPAppenderBase<ILoggingEvent> {

191

// Email-based alert system

192

}

193

194

public class SyslogAppender extends AppenderBase<ILoggingEvent> {

195

// Syslog protocol support

196

}

197

```

198

199

[Network Logging](./network-logging.md)

200

201

### Servlet Integration

202

203

Web application integration components for servlet containers.

204

205

```java { .api }

206

public class LogbackServletContextListener implements ServletContextListener {

207

// Servlet container lifecycle integration

208

}

209

210

public class LogbackServletContainerInitializer implements ServletContainerInitializer {

211

// Automatic servlet container setup

212

}

213

```

214

215

[Servlet Integration](./servlet-integration.md)

216

217

## Types

218

219

```java { .api }

220

// Core logging event interface

221

public interface ILoggingEvent {

222

String getThreadName();

223

Level getLevel();

224

String getMessage();

225

Object[] getArgumentArray();

226

String getFormattedMessage();

227

String getLoggerName();

228

IThrowableProxy getThrowableProxy();

229

long getTimeStamp();

230

Map<String, String> getMDCPropertyMap();

231

Marker getMarker();

232

}

233

234

// Exception handling

235

public interface IThrowableProxy {

236

String getMessage();

237

String getClassName();

238

StackTraceElementProxy[] getStackTraceElementProxyArray();

239

IThrowableProxy getCause();

240

}

241

242

// Context information

243

public class LoggerContextVO {

244

String getName();

245

Map<String, String> getPropertyMap();

246

long getBirthTime();

247

}

248

```