-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[MS25 & MS26] Unified date & time formatting #3139
Copy link
Copy link
Closed
Labels
STF-MilestonesMilestones funded by the Sovereign Tech FundMilestones funded by the Sovereign Tech FundlayoutsAffects one or more Layout pluginsAffects one or more Layout pluginsperformanceIssues or PRs that affect performance, throughput, latency, etc.Issues or PRs that affect performance, throughput, latency, etc.
Milestone
Metadata
Metadata
Assignees
Labels
STF-MilestonesMilestones funded by the Sovereign Tech FundMilestones funded by the Sovereign Tech FundlayoutsAffects one or more Layout pluginsAffects one or more Layout pluginsperformanceIssues or PRs that affect performance, throughput, latency, etc.Issues or PRs that affect performance, throughput, latency, etc.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In #3121, date & time formatting of both Pattern Layout and JSON Template Layout has been rewritten to be served from a unified utility using Java's
DateTimeFormatterunder the hood with some caching for extra efficiency.Historical account
MS25, MS26, MS27 had the following sequence of goals:
InstantFormatter(used for formatting log event instants) oflog4j-layout-template-jsontolog4j-coreInstantFormattermoved tolog4j-corein both JSON Template Layout and Pattern LayoutInstantFormattermoved tolog4j-corein other places where date & time formatting is neededWe encountered several blockers while executing this plan. Some highlights from the thinking process that led us to the current plan are shared below – see this
dev@discussion for details.FixedDateFormatandFastDateFormat.InstantFormatterleverages these two for date & time formatters for patterns they support, otherwise it falls back toDateTimeFormatter.InstantFormatteris moved tolog4j-coreand wired to Pattern Layout, several tests started failing, because previously employedFixedDateFormatisnandxdirectivesFixedDateFormatincorrectly calculates DST forAmerica/Santiagotime zone #2943)FastDateFormatwas copied from Commons Lang in 2015In short,
FixedDateFormatandFastDateFormatare liabilities (containing incorrect behaviour and bugs!) that once made sense for performance reasons. Though as shown with performance figures in #3121, the efficiency offered by this liability burden is negligible in the big picture of an end-to-end logging scenario. Eventually, we decided toDateTimeFormatterfor date & time formatting2024-10-29T14:49:53.997Zform, we only need to generate53.997each time and the rest can be precomputed per minute, cached, and reused)FixedDateFormatandFastDateFormatet al.FixedDateFormatincorrectly calculates DST forAmerica/Santiagotime zone #2943Log4j 3
#3150 ports #3121 from
2.xtomain, the Log4j 3 branch.