Skip to content

io microsphere logging AbstractLogger

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

AbstractLogger

Type: Class | Module: microsphere-java-core | Package: io.microsphere.logging | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/logging/AbstractLogger.java

Overview

An abstract implementation of the Logger interface, providing common functionality for concrete logger implementations.

This class ensures consistent handling of logging operations across different logging frameworks by implementing shared logic such as message formatting and exception handling. Subclasses are expected to implement the basic logging methods (e.g., #trace(String), #debug(String), etc.) according to their specific logging backend.

Message Formatting

The class supports formatted logging using a syntax similar to SLF4J or Java's String#format(String, Object...). For example:

`logger.info("User {` logged in from {}", username, ip);
}

Exception Logging

If the last argument passed to a formatted logging method is an instance of Throwable, it will be treated as an exception, and the appropriate method accepting both a message and a throwable will be invoked:

`try {
    // some operation that may throw an exception
` catch (Exception e) {
    logger.error("Operation failed", e);
}
}

This behavior is handled internally by the #log(Consumer, BiConsumer, String, Object...) method.

Declaration

public abstract class AbstractLogger implements Logger

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Example 1

logger.info("User {} logged in from {}", username, ip);

Example 2

try {
    // some operation that may throw an exception
} catch (Exception e) {
    logger.error("Operation failed", e);
}

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.logging.AbstractLogger;

API Reference

Public Methods

Method Description
getName
trace
debug
info
warn
error

See Also

  • Logger

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally