Skip to content

io microsphere logging log4j Log4jLogging

github-actions[bot] edited this page May 29, 2026 · 8 revisions

Log4jLogging

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

Source: microsphere-log4j/src/main/java/io/microsphere/logging/log4j/Log4jLogging.java

Overview

Logging class based on the Log4j framework.

Declaration

public class Log4jLogging implements Logging

Author: Mercy

Version Information

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

Method Examples

getRootLoggerName

Log4jLogging logging = new Log4jLogging();
  String rootName = logging.getRootLoggerName(); // "root"

getLoggerNames

Log4jLogging logging = new Log4jLogging();
  List<String> names = logging.getLoggerNames();

getSupportedLoggingLevels

Log4jLogging logging = new Log4jLogging();
  Set<String> levels = logging.getSupportedLoggingLevels();
  // e.g. ["OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"]

getLoggerLevel

Log4jLogging logging = new Log4jLogging();
  String level = logging.getLoggerLevel("io.microsphere"); // e.g. "INFO"

setLoggerLevel

Log4jLogging logging = new Log4jLogging();
  logging.setLoggerLevel("io.microsphere", "DEBUG");

getName

Log4jLogging logging = new Log4jLogging();
  String name = logging.getName(); // "Log4j"

getPriority

Log4jLogging logging = new Log4jLogging();
  int priority = logging.getPriority();
  // returns Log4jLogging.PRIORITY

Usage

Maven Dependency

Add the following dependency to your pom.xml:

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

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

Import

import io.microsphere.logging.log4j.Log4jLogging;

API Reference

Public Methods

Method Description
getRootLoggerName The priority of Log4jLogging
getLoggerNames {@inheritDoc}
getSupportedLoggingLevels {@inheritDoc}
getLoggerLevel {@inheritDoc}
setLoggerLevel {@inheritDoc}
getName {@inheritDoc}
getPriority {@inheritDoc}

Method Details

getRootLoggerName

public String getRootLoggerName()

The priority of Log4jLogging / public static final int PRIORITY = NORMAL_PRIORITY - 3;

/** All Logging Levels : "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"

getLoggerNames

public List<String> getLoggerNames()

{@inheritDoc}

Example Usage

`Log4jLogging logging = new Log4jLogging();
  List names = logging.getLoggerNames();
`

getSupportedLoggingLevels

public Set<String> getSupportedLoggingLevels()

{@inheritDoc}

Example Usage

`Log4jLogging logging = new Log4jLogging();
  Set levels = logging.getSupportedLoggingLevels();
  // e.g. ["OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"]
`

getLoggerLevel

public String getLoggerLevel(String loggerName)

{@inheritDoc}

Example Usage

`Log4jLogging logging = new Log4jLogging();
  String level = logging.getLoggerLevel("io.microsphere"); // e.g. "INFO"
`

setLoggerLevel

public void setLoggerLevel(String loggerName, String levelName)

{@inheritDoc}

Example Usage

`Log4jLogging logging = new Log4jLogging();
  logging.setLoggerLevel("io.microsphere", "DEBUG");
`

getName

public String getName()

{@inheritDoc}

Example Usage

`Log4jLogging logging = new Log4jLogging();
  String name = logging.getName(); // "Log4j"
`

getPriority

public int getPriority()

{@inheritDoc}

Example Usage

`Log4jLogging logging = new Log4jLogging();
  int priority = logging.getPriority();
  // returns Log4jLogging.PRIORITY
`

See Also

  • Logging

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

Clone this wiki locally