Sync 'dev' branch#13
Conversation
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 standardizes root logger handling across supported logging frameworks and reduces duplicated parent-logger resolution logic. Changes:
Technical Notes: Root logger names differ by framework (e.g., JUL/Log4j2 use 🤖 Was this summary useful? React with 👍 or 👎 |
| if (Objects.equals(getRootLoggerName(), loggerName)) { | ||
| return null; | ||
| } | ||
| int lastDotIndex = loggerName.lastIndexOf(DOT); |
There was a problem hiding this comment.
| @Nullable | ||
| String getParentLoggerName(String loggerName); | ||
| default String getParentLoggerName(String loggerName) { | ||
| if (Objects.equals(getRootLoggerName(), loggerName)) { |
There was a problem hiding this comment.
The Javadoc for getParentLoggerName still describes returning an empty string for the root logger, but the default implementation returns null when loggerName equals getRootLoggerName() (and may return a non-empty root name for top-level loggers like Logback).
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
This pull request introduces a new
getRootLoggerName()method to theLogginginterface and its implementations, standardizes the handling of root logger names across logging frameworks, and moves the default logic for determining a parent logger name into the interface itself. It also refactors and cleans up related code and tests, and renames the Log4j logger class for clarity.API and Interface Changes
getRootLoggerName()method to theLogginginterface, with implementations provided for Java Util Logging, Log4j, Log4j2, and Logback. This method returns the name of the root logger for each framework. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ab0af1d580b76d9d2ec03297ffbd99f5c641f40c822a77fb561b2165b2af3f0aR41-R48),[[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-820f87886e6263649e34cfd61a02fdd044a7785d69d26409f016834b356d4858R39-R43),[[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-904199cabf9b2ce4a054a31a6d7b9177a85a97642acdd2be224d2a6db284e2f1R59-R63),[[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-96dbc8b1d7ea6a605251799aa481feedeaba3ee62f20f6a183fd5e72f34356c8R55-R59),[[5]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ccade0afe08029cad82834690a561b28ba804ce7c0dafc81b3064eaaba323701R55-R59))getParentLoggerName()into theLogginginterface. Implementations now inherit this logic, reducing code duplication. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ab0af1d580b76d9d2ec03297ffbd99f5c641f40c822a77fb561b2165b2af3f0aL107-R128),[[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-904199cabf9b2ce4a054a31a6d7b9177a85a97642acdd2be224d2a6db284e2f1L85-L97),[[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-96dbc8b1d7ea6a605251799aa481feedeaba3ee62f20f6a183fd5e72f34356c8L79-L91),[[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ccade0afe08029cad82834690a561b28ba804ce7c0dafc81b3064eaaba323701L79-L91))Log4j Module Refactoring
Log4j2LoggertoLog4jLoggerfor clarity, updated all usages, and adjusted related test classes and documentation. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-e9fd7d5fe56e264a506148b2acd0808287c0430d095c5f402ebda1b97c6557d5L36-R40),[[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-5c4d858300434dacb607e055a9d512d1aea8dc35a40f41cccfcc77448ccaa960L43-R43),[[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-86923048db8ddb54676686dde1ed6a8e2943be536ef509173ed135ff308bda50L54-R54),[[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-911434e95cfb295581e764104a13c5b9673676a162ce0a912563082c244da7b0L33-R47))LoggerUtils. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-d82736e2f57822c9a055a8312ed885004298e7440c98cf554bf95b93e289782aL32-R32),[[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-d82736e2f57822c9a055a8312ed885004298e7440c98cf554bf95b93e289782aR42-R44))Testing Improvements
getRootLoggerName()method in all logging modules to ensure correct behavior. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ef8e18132b898d65cf9fd504eb439a697f96307e91f959e83d560bac6f749208L49-R116),[[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-3d2a9c1e99f64926b64a67a9f45e923474d86f3eee32ea76623643c1f8e8efe5R62-R71),[[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-0b4ee10b418b329de4ecb190981a84293c95c0c7cb5b9dd6f9276fd001a4b65cR66-R70),[[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-0c42b56500cd52008c55385517b2ba6058f8bd94dcb899b36afcddcef139de0eR68-R72))Documentation
README.md. ([README.mdR221](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R221))