liveBook · Manning

Logger

As explained in Troubleshooting Java, Second Edition

A logger is a Log4j component or object that accepts application messages at specified severity levels.

A logger is a Log4j component or object that accepts application messages at chosen severity levels. Create one with LogManager.getLogger(), then write messages with methods such as info() and debug(). section 4.2.2

Logging becomes useful during investigation when severity controls how much execution detail appears. An info-level logger records operational events, while debug enables fine-grained observations when needed. section 4.2.2

Treat the logger as one part of a configurable logging pipeline:

  • Selects which messages qualify, such as all application messages or messages from a specific application part. section 4.2.2

Tracing digit extraction

A StringDigitExtractor logger records the start and result at info level, then records each parsed character at debug level. With a Root level of info, only the start and result appear; changing the Root level to debug exposes the character-by-character trace.

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains creation, severity methods, configuration, appenders, and formatters, but does not descend into framework internals.
Examples
Uses a StringDigitExtractor, Log4j API calls, log4j2.xml configuration, console output, and adjustable info/debug thresholds.
What it assumes
Assumes a Java application and Maven project, while introducing Log4j dependencies, logger creation, and XML configuration.
What you can do after
Apply it via Log4j to emit severity-specific messages and configure their selection, destination, and formatting.
How it connects
Connects loggers to severity levels, LogManager, appenders, formatters, and XML configuration.

Also explained in

Compare how 5 books explain Logger →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.