Skip to content

io microsphere logging Logger

github-actions[bot] edited this page Mar 24, 2026 · 3 revisions

Logger

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

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

Overview

Logger interface for logging messages with different severity levels.

The Logger provides methods to log messages at various levels such as TRACE, DEBUG, INFO, WARN, and ERROR. Each level has corresponding methods to check if the level is enabled (isXxxEnabled()) and to log messages either as simple strings, formatted strings, or with associated exceptions.

Example Usage

Basic Usage

`if (logger.isInfoEnabled()) {
    logger.info("Application started successfully.");
`
}

Formatted Logging

`String user = "JohnDoe";
int attempts = 3;
logger.warn("User '{`' exceeded maximum login attempts: {}", user, attempts);
}

Logging Exceptions

`try {
    // some operation that may fail
` catch (Exception e) {
    logger.error("An error occurred during processing", e);
}
}

Conditional Logging

`if (logger.isDebugEnabled()) {
    logger.debug("Detailed debug information: {`", generateDebugData());
}
}

Declaration

public interface Logger

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.2-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

if (logger.isInfoEnabled()) {
    logger.info("Application started successfully.");
}

Example 2

String user = "JohnDoe";
int attempts = 3;
logger.warn("User '{}' exceeded maximum login attempts: {}", user, attempts);

Example 3

try {
    // some operation that may fail
} catch (Exception e) {
    logger.error("An error occurred during processing", e);
}

Example 4

if (logger.isDebugEnabled()) {
    logger.debug("Detailed debug information: {}", generateDebugData());
}

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.Logger;

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

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally