Skip to content

Dev#5

Merged
mercyblitz merged 4 commits into
mainfrom
dev
Mar 15, 2026
Merged

Dev#5
mercyblitz merged 4 commits into
mainfrom
dev

Conversation

@mercyblitz
Copy link
Copy Markdown
Contributor

This pull request introduces Log4j2 support to the Microsphere Logging framework, along with related documentation, dependency, and test updates. The changes add a new microsphere-logging-log4j2 module, implement the necessary integration classes, update the project structure and dependencies, and provide comprehensive tests for the new functionality.

Log4j2 Integration:

  • Added a new module, microsphere-logging-log4j2, including its Maven POM with dependencies for Log4j2, core logging, and testing libraries.
  • Implemented Log4j2Logging, a Logging interface implementation for Log4j2, providing methods for logger management and level control.
  • Added LoggerUtils utility class for working with Log4j2 loggers, including methods to get/set logger levels and retrieve logger context.
  • Registered the Log4j2 logging implementation via the Java service loader mechanism.

Testing and Configuration:

  • Added unit tests for Log4j2Logging and LoggerUtils to verify logger name retrieval, level support, parent logger resolution, and level setting. [1] [2]
  • Included a sample log4j2.xml configuration for testing purposes.

Project Structure and Dependency Updates:

  • Updated the root README.md to document the new Log4j2 module and clarify module purposes.
  • Added the new module as a dependency in microsphere-logging-dependencies/pom.xml.
  • Updated parent POM to include JUnit BOM and dependencies for improved test support.

Code Quality Improvements:

  • Refactored test code in ThrowableLogging to use emptyList() and emptySet() for clarity and consistency. [1] [2] [3]

These changes collectively enable Log4j2 support in the Microsphere Logging framework and improve overall project structure and testability.

Replace List.of() and Set.of() with static imports of Collections.emptyList() and emptySet() in ThrowableLogging test. Also remove an extraneous blank line in setLoggerLevel(). These changes clarify intent and can improve compatibility with older Java versions.
Relocate the JUnit BOM and junit dependency to the top of the dependencyManagement section and remove their duplicate entries later in the file. Uses ${junit-jupiter.version} for the BOM and ${junit.version} for junit; this cleans up the POM organization and avoids duplicated dependency declarations.
Reorder and clean up the modules table in the README: simplify wording for the core and test modules, clarify the parent and dependencies entries, and add a new microsphere-logging-logback module for Logback extensions. Also adjust table formatting for clearer presentation.
Introduce a new microsphere-logging-log4j2 module to provide a Log4j2-backed implementation of the Logging SPI. Adds module POM, main implementation (Log4j2Logging), utility class (LoggerUtils), service registration, Log4j2 test config, and unit tests. Also updates the aggregator pom.xml to include the new module and adds the new artifact to microsphere-logging-dependencies/pom.xml.
@mercyblitz mercyblitz merged commit 40365f9 into main Mar 15, 2026
13 checks passed
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 15, 2026

🤖 Augment PR Summary

Summary: This PR introduces Log4j2 support to Microsphere Logging by adding a dedicated integration module.

Changes:

  • Added new microsphere-logging-log4j2 Maven module and wired it into the root reactor + dependency management BOM
  • Implemented Log4j2Logging (a Logging SPI provider) and a Log4j2-specific LoggerUtils helper
  • Registered the provider via META-INF/services/io.microsphere.logging.Logging
  • Added JUnit Jupiter tests plus a log4j2.xml test configuration to validate names, levels, and parent logger resolution
  • Minor test cleanup in ThrowableLogging and small dependency-management reordering in the parent POM

Technical Notes: The integration relies on Log4j2 core APIs (logger context + level control) and is discovered through Java SPI at runtime.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 4 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread README.md
microsphere-logging-parent | Parent POM with shared configurations.
microsphere-logging-dependencies | Manages dependency versions across the project.
microsphere-logging-core | Provides the core features for logging.
microsphere-logging-logback | Provides the extensions features for logback.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Modules table doesn’t list microsphere-logging-log4j2 even though this PR adds that module to the build, so the README may be out of sync for users looking for Log4j2 support.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

<version>${revision}</version>
<packaging>jar</packaging>

<name>Microsphere :: Logging :: Logj4</name>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Maven <name> is Microsphere :: Logging :: Logj4, which looks like a typo and will show up in published artifact metadata.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<optional>true</optional>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this module registers a Logging provider via SPI, making log4j-api/log4j-core optional can cause ServiceLoader/ServiceConfigurationError at runtime if a consumer includes this module but doesn’t also include Log4j2 on the classpath.

Severity: medium

Other Locations
  • microsphere-logging-log4j2/pom.xml:53

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

* @see Log4j2Logging
* @since 1.0.0
*/
class Log4j2LoggingTest {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: microsphere-logging-log4j2/src/test/resources/META-INF/services/io.microsphere.logging.Logging currently lists io.microsphere.logging.ThrowableLogging, which is a test-only class from microsphere-logging-core and isn’t on this module’s test classpath; any call to LoggingUtils.loadAll() during these tests would fail with a ServiceConfigurationError.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant