Skip to content

Refactor StatusLogger to use precompiled Pattern constants #3719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

kamilkrzywanski
Copy link

We should improve the implementation of StatusLogger by extracting all regular expressions used for property normalization and matching into clearly named, precompiled Pattern constants. This change would:

Avoid repeated calls to Pattern.compile(...), improving performance.
Increase readability and maintainability by clearly naming intent of regex patterns.

@vy
Copy link
Member

vy commented Jun 8, 2025

We should improve the implementation of StatusLogger by extracting all regular expressions used for property normalization and matching into clearly named, precompiled Pattern constants.

Should we? Aren't these only used once during the Config singleton initialization? Would you mind sharing the performance problem you're having?

@vy vy added the waiting-for-user More information is needed from the user label Jun 8, 2025
@vy vy self-assigned this Jun 8, 2025
@vy vy added api Affects the public API performance Issues or PRs that affect performance, throughput, latency, etc. labels Jun 8, 2025
@ppkarwasz
Copy link
Contributor

The normalization logic in StatusLogger only needs to support the five legacy constants listed below and their corresponding normalized forms. There's no need for complex logic or performance optimizations here — defining four simple lookup tables to map between the different formats should be sufficient.

Legacy Constant Normalized Forms
log4j2.debug Normal: log4j2.debug
Env Var: LOG4J_DEBUG
Log4j 3: log4j.debug
log4j2.status.entries Normal: log4j2.statusEntries
Env Var: LOG4J_STATUS_ENTRIES
Log4j 3: log4j.statusLogger.statusEntries
log4j2.StatusLogger.level Normal: log4j2.statusLoggerLevel
Env Var: LOG4J_STATUS_LOGGER_LEVEL
Log4j 3: log4j.statusLogger.level
log4j2.StatusLogger.dateFormat Normal: log4j2.statusLoggerDateFormat
Env Var: LOG4J_STATUS_LOGGER_DATE_FORMAT
Log4j 3: log4j.statusLogger.dateFormat
log4j2.StatusLogger.dateFormatZone Normal: log4j2.statusLoggerDateFormatZone
Env Var: LOG4J_STATUS_LOGGER_DATE_FORMAT_ZONE
Log4j 3: log4j.statusLogger.dateFormatZone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the public API performance Issues or PRs that affect performance, throughput, latency, etc. waiting-for-user More information is needed from the user
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

3 participants