Conversation
Expand .gitignore to ignore common build artifacts, IDE project files (Eclipse/IntelliJ), temp/log/cache files, system files, Maven/Gradle outputs and compiler build dirs. Keeps .mvn/wrapper files explicitly and removes the obsolete replay_pid* entry. This reduces noise in VCS by excluding generated and environment-specific files.
Add CODE_OF_CONDUCT.md adapted from the Contributor Covenant v1.3.0. Defines expected community behavior and lists examples of unacceptable conduct, outlines maintainer responsibilities and enforcement, and provides a reporting contact (mercyblitz@gmail.com).
Replace minimal README with a comprehensive project README including badges, project introduction, module overview, getting-started instructions (BOM and dependency examples), build steps for Linux/Mac and Windows, contributing and issue reporting guidance, documentation links (DeepWiki, ZRead, GitHub Wiki), and license. Includes placeholders (TODO) for content and examples to be filled in later to improve onboarding and project visibility.
Introduce an initial Maven multi-module scaffold for the microsphere-logging project. Adds root pom.xml plus module poms: microsphere-logging-parent (central dependencyManagement and version properties for microsphere-java, slf4j, logback, junit), microsphere-logging-dependencies (dependencyManagement entry), microsphere-logging-core and microsphere-logging-test (module placeholders). The root POM defines project metadata, modules list, revision/java.version properties, SCM, distributionManagement and a snapshot repository.
Delete distributionManagement and repositories blocks referencing OSSRH (snapshot and staging) from the root pom.xml. Cleans up hardcoded Sonatype snapshot/staging configuration from the project POM.
Add Maven Wrapper files (mvnw, mvnw.cmd, .mvn/wrapper/maven-wrapper.properties) to pin Maven distribution (wrapperVersion 3.3.4) and use an Aliyun distribution URL. Add two GitHub Actions workflows: maven-build.yml (build/test matrix for Java 17/21/25 on dev and PRs, runs tests with test/coverage profiles and uploads Codecov) and maven-publish.yml (release branch publish with workflow_dispatch, deploys to OSSRH using secrets and publish/ci profiles). Also include a minor whitespace/newline cleanup in pom.xml.
Update Maven <revision> in pom.xml from 0.0.1-SNAPSHOT to 0.2.0-SNAPSHOT to reflect the new development version.
Introduce a logging core API and JDK-based implementation with JMX support and unit tests. Adds Logging interface, StandardLogging (JDK) implementation, LoggingMXBeanAdapter and PlatformLoggingMXBeanRegistrar to register Logging instances via the platform MBean server. Includes tests (StandardLoggingTest, LoggingMXBeanAdapterTest, PlatformLoggingMXBeanRegistrarTest) and a ThrowableLogging test provider plus a service loader resource. Update POMs: change packaging of core and test modules to jar and add optional/runtime/test dependencies (SLF4J, commons-logging, logback, junit, microsphere-java modules) and parent BOM dependency entries (JSR305, commons-logging, slf4j, logback). These changes provide a pluggable logging abstraction and automatic JMX registration for available implementations.
Introduce a register(ClassLoader) overload and make register() delegate to it using ClassLoaderUtils.getClassLoader. Replace direct ServiceLoader.load usage with ServiceLoaderUtils.loadServicesList and iterate as Iterable<Logging>, allowing explicit classloader control when discovering Logging implementations. Update imports accordingly and remove the unused ServiceLoader.load import.
Introduce LoggingMXBeanRegistrar (io.microsphere.logging.jmx) and remove the old PlatformLoggingMXBeanRegistrar. The new registrar loads Logging implementations via ServiceLoader, registers/adapts them to LoggingMXBean with improved handling for already-registered MBeans, exposes a JMX_DOMAIN constant (io.microsphere.logging) and provides getRegisteredLoggingObjectInstances(). Tests were renamed/updated to LoggingMXBeanRegistrarTest and adapted to the new API (constants, registerAll, getRegisteredLoggingObjectInstances) and utilities.
Align Codecov configuration and README badge: update the codecov action slug from microsphere-projects/microsphere-spring to microsphere-projects/microsphere-logging and change the README Codecov badge to point at the dev branch. This ensures coverage uploads and the badge reference target the correct repository and branch.
Introduce a LoggingLevelsResolver API and a DefaultLoggingLevelsResolver implementation (with unit tests) to derive supported logging level names from framework Level classes. Rename Logging.getSupportedLogLevels() to getSupportedLoggingLevels() and update implementations/tests (StandardLogging, ThrowableLogging, related tests) accordingly. Add a new microsphere-logging-logback module with a LogbackLogging stub and service descriptor for testing. Update POMs: add commons-logging, Log4j 1.x/2.x and Logback dependencies and version properties, register the new module, and include the logback/test artifacts in dependency management. These changes enable unified resolution of logging levels across multiple logging frameworks and add initial Logback support; note the API method rename is a breaking change that required test and implementation updates.
Change LoggingMXBeanRegistrar to an abstract class and add a private no-arg constructor to prevent instantiation, enforcing non-instantiable/utility-style usage for the registrar.
Integrate LogbackLogging with Logback API: use LoggerContext to list loggers, get/set levels, resolve supported levels, and determine parent logger names. Remove an optional microsphere-java-core dependency from the module POM. Add unit tests and a test Logback configuration (logback-test.xml) to validate behavior.
Add a new LoggerUtils utility class to encapsulate Logback interactions (getLoggerContext, getLogger, getLevel, getLevelString, setLoggerLevel). Refactor LogbackLogging to delegate level and logger lookups to LoggerUtils and remove its direct LoggerContext field and getLogger method. Update tests: remove the direct null-logger call in LogbackLoggingTest and add comprehensive LoggerUtilsTest to cover the new utility behavior. This centralizes Logback logic for reuse and improves testability.
Introduce LoggingUtils to centralize SPI-based Loading of Logging implementations (loadAll(ClassLoader)). Make Logging extend Prioritized so implementations can provide priority; add getPriority() implementation in StandardLogging returning MIN_PRIORITY. Update LoggingMXBeanRegistrar to use LoggingUtils.loadAll instead of ServiceLoader directly. Add unit test LoggingUtilsTest to validate SPI loading behavior. Small refactors: added necessary imports and a private constructor to LoggingUtils.
Update parent POM to support both JUnit 4 and JUnit Jupiter: set junit.version to 4.13.2, add junit-jupiter.version property, import the JUnit BOM using the Jupiter version, and add a managed junit (JUnit 4) entry. Add test module dependencies in microsphere-logging-test: include microsphere-logging-core, optional microsphere-java artifacts, JUnit 4 and JUnit Jupiter (including the engine), and test logging libraries (slf4j-api and logback-classic). These changes enable running tests with both JUnit 4 and JUnit 5 and provide required test/logging dependencies for the test module.
Add META-INF/services/io.microsphere.logging.Logging registering io.microsphere.logging.logback.LogbackLogging so the Logback implementation can be discovered via ServiceLoader.
Introduce a JUnit4 TestRule to run tests across different logging levels. Adds LoggingLevelsRule and LoggingLevelsStatement which iterate configured levels, set/reset the logger level for the test class, and invoke the test Statement for each level. Includes a basic LoggingLevelsRuleTest that demonstrates using the rule with TRACE/DEBUG/INFO. Also updates the module POM to add a test-scope dependency on microsphere-logging-logback.
Add a static import of org.junit.Assert.assertNotNull and call assertNotNull(loggingLevelsRule) in LoggingLevelsRuleTest.test() to verify the ClassRule is initialized.
Introduce a JUnit Jupiter @LoggingLevelsTest annotation and a LoggingLevelsTestExtension that provides class- and test-template invocation contexts to repeat tests across specified logging levels. The extension sets and resets logger levels for discovered Logging implementations and supplies parameters (level and index) to tests. Add example test classes (one commented method-level example and one active class-level test). Also fix JUnit4 LoggingLevelsStatement to use the test class package name for logger lookup (use package name instead of class name).
Add org.junit.vintage:junit-vintage-engine as a test dependency in microsphere-logging-test/pom.xml to enable JUnit Vintage support. Remove an outdated paragraph from the LoggingLevelsStatement Javadoc in microsphere-logging-test/src/main/java/io/microsphere/logging/test/junit4/LoggingLevelsStatement.java that described constructor signature requirements.
Add a suite of JUnit Jupiter utilities to run tests across different logging levels and manage logger state. New annotations LoggingLevelsTest and LoggingLevelsClass (class-level template) allow specifying target logging classes and levels. Implement a reusable generic LoggingLevelsExtension with concrete LoggingLevelsTestExtension and LoggingLevelsClassExtension, plus helper classes LoggingLevelCallback, LoggingLevelParameterResolver, LoggingLevelTemplateInvocationContext and a LoggingLevelsAttributes model. Update and add tests (LoggingLevelsClassTest, LoggingLevelsTestTest) and refactor previous inline logic into the new extension infrastructure to set/restore logger levels and inject level/index parameters into test methods.
Enhance LoggerUtilsTest by adding an assertion that getLogger(Class) returns a non-null logger instance (assertNotNull(getLogger(LoggerUtilsTest.class))). This verifies the class-based overload of getLogger; existing null and illegal-argument tests remain unchanged.
Replace utility-based parent lookup with direct string operations. The code now uses lastIndexOf/substring to compute the parent logger name and no longer checks for the parent Logger's existence (removing dependency on getLogger and substringBeforeLast). Behavior: if there's no dot in the name it returns the root logger name, otherwise returns the substring before the last dot. Unused imports were removed.
Sync 'dev' branch
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.
Use Collections.emptyList/emptySet in ThrowableLogging test for compatibility and to avoid Java 9+ APIs. Update parent POM dependency versions and management: set slf4j to 1.7.36, logback to 1.2.12, bump junit-jupiter to 5.14.3, and consolidate JUnit BOM and junit entries in dependencyManagement. Adjust root POM revision to 0.1.0-SNAPSHOT and remove the explicit java.version property.
Change the Codecov badge URL in README.md to reference the dev-1.x branch instead of dev so the coverage badge points to the correct branch after the branch rename.
Update module list and dependency example to reflect refactored module names: replace microsphere-logging-core with microsphere-logging-commons, microsphere-logging-jdk with microsphere-java-logging, and rename microsphere-logging-logback/log4j2 to microsphere-logback/microsphere-log4j2. Adjust the sample dependency artifactId accordingly to keep documentation consistent with the project changes.
Introduce LoggingUtils.load() and load(ClassLoader) to return the highest-priority Logging implementation from SPI (uses Prioritized and ServiceLoaderUtils.loadFirstService). Update Javadoc to clarify priority ordering for loadAll, add unit test (testLoad) asserting the prioritized implementation is returned, and set MAX_PRIORITY in TestingLogging by implementing getPriority(). Minor import adjustments.
Replace direct instantiation of LogbackLogging with a call to LoggingUtils.load() in the test setup and add the corresponding static import. This ensures the test uses the configured loader/factory instance (cast to LogbackLogging) rather than creating a new instance directly.
Replace the previous service loader call with LoggingUtils.load() in JavaLoggingTest#setUp. Removed the unused io.microsphere.logging.Logging import and the old loadFirstService static import, and added a static import for io.microsphere.logging.LoggingUtils.load. This simplifies obtaining the JavaLogging test instance.
Replace ServiceLoaderUtils.loadFirstService(Logging.class) with LoggingUtils.load in Log4j2LoggingTest#setUp to simplify loading the Logging implementation. Remove the now-unused io.microsphere.logging.Logging import and the static ServiceLoaderUtils import, and add a static import for LoggingUtils.load.
Deletes the microsphere-java-annotations dependency and removes the <optional>true</optional> flag from microsphere-java-core in microsphere-logging-commons/pom.xml. This ensures microsphere-java-core is always brought in and removes an unnecessary annotations dependency.
Introduce a new microsphere-logging-examples Maven module with its own POM. The module declares dependencies on microsphere-java-logging, microsphere-logback, microsphere-log4j2 and concrete Logback/Log4j2 artifacts, and disables deployment for example builds. Add a LoggingExample Java class that demonstrates loading the highest-priority Logging implementation and logging its name and logger names. Include a simple log4j2.xml that configures a console appender and root logger. Also update the parent pom.xml to register the new module.
Add Versions and Compatibility sections to README outlining supported Java, JUnit, SLF4J, Logback and Log4j2 for 0.2.x and 0.1.x. Update dependency examples to include microsphere-java-logging, microsphere-logback, microsphere-log4j2 and their runtime deps (logback, log4j2), replacing the old microsphere-logging-commons artifact in the sample. Include a Java usage example showing how to load the Logging instance and sample run output, and reference the microsphere-logging-examples module for more samples.
Replace placeholder TODOs with a brief introduction to the Microsphere Logging Framework and a concise feature list. Describes the framework purpose and key capabilities: runtime log level management, framework-agn API (Logback/Log4j2/Java Logging), JMX operational control, testing infrastructure, and multi-tenant logging configuration support.
Sync 'dev' branch
Update the README logging frameworks list to include Log4j 1.2+ and raise the documented minimum Log4j2 version from 2.0+ to 2.4+. This keeps the documentation in sync with supported/required logging dependencies.
README: add Log4j 1.2 and bump Log4j2
Delete Apache Commons Logging config from microsphere-logging-parent/pom.xml: the <apache-commons-logging.version> property and the commons-logging dependency were removed. Logging dependencies remain managed via the existing SLF4J/Log4J entries in the parent POM.
Remove the legacy Log4j 1.x property and dependency from microsphere-logging-parent POM (log4j.version and log4j:log4j 1.2.17). Update comment to reflect Log4j2 usage and keep Log4j2 (log4j-api) dependency. This drops support for the old Log4j 1.x artifact in favor of Log4j2.
Add a new property <log4j.version>1.2.17</log4j.version> and include the log4j:log4j dependency using that version in microsphere-logging-parent/pom.xml. This ensures legacy Log4j 1.2.17 is available for modules that require compatibility with older logging integrations.
Correct the <name> element in microsphere-log4j2/pom.xml from 'Microsphere :: Logging :: Logj4' to 'Microsphere :: Logging :: Log4j2' to fix a typo and align the module name with the project. No functional changes.
Update .github/workflows/maven-build.yml: remove 'main' from pull_request branches (PRs now trigger only for dev and release) and expand the Java test matrix to include Java 8 and 11 alongside 17, 21 and 25 to broaden CI coverage for older JDKs.
Update .github/workflows/maven-publish.yml: change the default revision from '2.0.0-SNAPSHOT' to '1.0.0-SNAPSHOT' and switch the Actions Java runtime from 17 to 11 (temurin). Aligns the workflow with the intended default publish version and Java compatibility.
Normalize log4j section comments in microsphere-logging-commons/pom.xml: change "Log4j 1.x" to "Log4j" and "Log4j 2.x" to "Log4j2". No dependency or functional changes—just comment text for clarity.
Introduce a new microsphere-log4j module providing Log4j support: add implementation classes (Log4j2Logger, Log4jLoggerFactory, Log4jLogging, LoggerUtils), service loader entries, test suite and a test log4j.xml. Integrate the module into the build by updating root pom (add module, adjust revision/java.version), include the module in microsphere-logging-dependencies and examples poms, and add Log4j dependencies to README and examples. Also update microsphere-logging-parent: bump junit-jupiter.version and add Java 8/17+ profiles to manage compatibility.
Rename the Log4j logger implementation from Log4j2Logger to Log4jLogger (class and constructor) across the microsphere-log4j module. Update Log4jLoggerFactory to return the renamed class and adjust unit tests and Javadoc references accordingly. Also add microsphere-log4j link to the README.
Introduce getRootLoggerName() to the Logging API and implement it in concrete logging adapters. Add ROOT_LOGGER_NAME constants (Java logging and Log4j util) and update tests to assert root name. Move parent resolution into a default getParentLoggerName() in Logging (using DOT) and remove duplicated parent-lookup implementations from Log4j, Log4j2 and Logback. Update TestingLogging and ThrowableLogging test helpers to return a root name, and adjust tests (variable rename and assertions) accordingly.
Add a new LoggingTest unit test to verify Logging behavior (root name, logger names, supported levels, get/set level, parent names, name and priority). Update TestingLogging to use a linked (ordered) map by replacing HashMap with MapUtils.newLinkedHashMap and adding the corresponding static import, ensuring logger insertion order is preserved and removing the unused HashMap import.
Import assertNull and add an assertion verifying that Logging.getParentLoggerName("") returns null. This ensures the logging implementation correctly handles an empty logger name case in tests.
🤖 Augment PR SummarySummary: This PR prepares the initial Changes:
Technical Notes: Logging backend selection relies on SPI discovery with 🤖 Was this summary useful? React with 👍 or 👎 |
| } | ||
|
|
||
| private static ObjectName createObjectName(String type) throws MalformedObjectNameException { | ||
| return getInstance(JMX_DOMAIN + ":type=" + type); |
There was a problem hiding this comment.
ObjectName property values can’t contain spaces unless quoted/escaped; using logging.getName() directly means a provider like Java Logging will trigger MalformedObjectNameException and silently skip MXBean registration.
Severity: high
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| return this.logging.equals(obj); |
There was a problem hiding this comment.
Delegating equals() to this.logging.equals(obj) breaks the equals contract (e.g., adapter.equals(logging) may be true while logging.equals(adapter) is false), which can cause very surprising behavior in sets/maps.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| @Nullable | ||
| default String getParentLoggerName(String loggerName) { | ||
| if (Objects.equals(getRootLoggerName(), loggerName)) { | ||
| return null; |
There was a problem hiding this comment.
The getParentLoggerName Javadoc says the root logger’s parent should be an empty string (matching LoggingMXBean), but the default implementation returns null when loggerName equals getRootLoggerName(), which may violate the documented/MXBean contract.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| try { | ||
| for (String level : levels) { | ||
| description.addChild(createTestDescription(testClass, description.getMethodName() + " with logging level - " + level)); | ||
| logging.setLoggerLevel(loggerName, level); |
There was a problem hiding this comment.
This calls logging.setLoggerLevel(loggerName, level) for a package-derived loggerName without ensuring that logger exists; per Logging#setLoggerLevel contract, implementations (notably JUL via LoggingMXBean) may throw IllegalArgumentException here.
Severity: medium
Other Locations
microsphere-logging-test/src/main/java/io/microsphere/logging/test/jupiter/extension/logging/LoggingLevelCallback.java:67
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
This pull request introduces the initial implementation of the Microsphere Java Logging module, providing Java Util Logging (JUL) support as part of the Microsphere Logging Framework. It also adds essential project infrastructure, including build and CI/CD workflows, project documentation, and a code of conduct. The most important changes are grouped below:
Microsphere Java Logging Module Implementation:
microsphere-java-loggingmodule with its ownpom.xml, defining dependencies on the commons module and test frameworks.JavaLoggingclass, which provides a concreteLoggingabstraction for Java Util Logging, exposing runtime log level management and logger introspection.JavaLoggingas a service provider via theMETA-INF/services/io.microsphere.logging.Loggingfile.JavaLogginginJavaLoggingTest.java.Project Infrastructure and CI/CD:
Documentation and Community Guidelines:
README.mdto provide a detailed introduction, feature list, module overview, compatibility matrix, usage examples, build instructions, and links to documentation.CODE_OF_CONDUCT.mdbased on the Contributor Covenant to establish community standards.