Java - Logger

Java Conceptuel Diagram

About

A Logger is the entry point to logs messages.

The main entity on which applications make logging calls. A Logger object is used to log messages.

Structure

  • It has a hierarchical scope that is generally the full qualified class name Example: com.example.app.MyClass.
  • Inheritance: A child Logger inherits any configured properties from its parent Logger.
  • Loggers are normally named entities, using dot-separated names such as “java.awt”.
  • The namespace is hierarchical and is managed by a LogManager.
  • The namespace is typically aligned with the Java packaging namespace
  • Loggers keep track of their parent loggers in the logging namespace. The root Logger (generally named the empty string “”) has no parent.

Properties

Level

Loggers may be assigned levels. For instance, TRACE, DEBUG, INFO, WARN and ERROR

The level filter the messages by their severity that this logger will append.

Example: A logger level of warning will not log any info message.

The effective level for a given logger is equal to the first non-null level in its hierarchy, starting at itself and proceeding upwards in the hierarchy towards the root logger.

Example:

  • if the logger with the name com.example.myapp.mypackage has been set to the level info
  • then the logger with the name com.example.myapp.mypackage.MyClass will have the level of its parent info. You may set a level to overwrite it.

The root logger has by default a level (generally DEBUG)

Management

Create/Get

A static logger factory is the entry point to get or create a logger

Example:

// get the fully qualified name of the class by default
protected static final Logger logger = LogManager.getLogger();
Logger x = LoggerFactory.getLogger("x.y.x"); 





Discover More
Java Conceptuel Diagram
Java - (Debugging) Logger, Logging system

in Java. A configuration provide specifications for: Logger objects - A Logger is the entry point to logs messages. Appenders (or Handlers) define where to write the message (console stdout,...
Java Conceptuel Diagram
Java - Appender (or Handlers)

An Appenders (or Handlers) define where to write the message also called Logging endpoints or output destination Logger delegates the task of writing a logging event to components called appenders More...
Java Conceptuel Diagram
Java - Log4j

Log4j is a debugging logger. version: 1.2 (2015 switch to 2.x) 2 Get a logger The name of this Logger will be the...
Java Conceptuel Diagram
Java - Slf4j

slf4j ) is a façade for loggers. To use a specific logger, add one of the binding logger package. Library should declare a runtime dependency only on on slf4j-api and not on any SLF4J binding but...
Java Conceptuel Diagram
Java - java.util.logging (JUL) or JDK logging

A logger since java 1.4.2, the java/util/logging/package-summaryJavaTM Logging APIs was introduced in package java.util.logging. See also: guides/logging/overviewTechnote Logging Overview If...
Java Conceptuel Diagram
Logging - Logger Manager | Logger Factory

A static logger factory is the entry point to get/create/retrieve a logger Logger Manager manages the loggers and its hierarchical namespace (ie if a logger has a parent it will inherit all properties...



Share this page:
Follow us:
Task Runner