Skip to content

Sanitize legacy dir.logs Log4j property before server startup#4

Closed
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-log4j2-properties-invalid-line
Closed

Sanitize legacy dir.logs Log4j property before server startup#4
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-log4j2-properties-invalid-line

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 26, 2026

Recent Log4j updates made the long-invalid dir.logs = logs entry fatal during configuration parsing, which can prevent the server from starting on upgraded installs. This change restores the original CLI behavior, keeps the shipped config files unchanged, and strips the bad server-side entry from existing server configs before Log4j initializes.

  • Startup-time remediation for existing server installs

    • Add a small pre-Log4j sanitizer in the server launcher.
    • Scan server/conf/log4j2.properties before logger initialization and remove any dir.logs assignment, regardless of surrounding whitespace.
  • Scope correction

    • Revert the earlier charset-targeting changes.
    • Restore the original CLI launcher and CLI Log4j config behavior.
    • Do not modify the valid property.log.dir setting.
  • Regression coverage

    • Add a focused server launcher test covering sanitizer behavior on a properties file containing the invalid dir.logs line.
    • Verify that dir.logs is removed while property.log.dir remains intact.

Example of the sanitized entry:

dir.logs = logs

After this change, server startup removes that legacy line before Log4j reads the file, allowing existing upgraded server configs to continue loading without manual edits.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Refactors the ToStringStyle implementations for MessageFilter and related
search elements to significantly improve debuggability and log readability.

Key Changes:
- Refactored MetaDataSearchElementToStringStyle into a generic
  SearchElementToStringStyle to eliminate code duplication.
- Added ContentSearchElementToStringStyle:
  - Converts raw content codes into human-readable ContentType names
    (e.g., "1(Raw)") instead of opaque integers.
- Updated MessageFilterToStringStyle:
  - Replaced legacy Calendar formatting with java.time (ZonedDateTime)
    and included time and timezone id.
  - Added recursive indentation logic to render nested collections
    in a hierarchical format.
- Applied new styles to ContentSearchElement and MetaDataSearchElement
  toString() methods.
- Previously ContentSearchElement was inheriting the Object.toString
  method.

This change primarily adds detail for ContentSearchElements when viewing
the MessageFilter in the server event log. The addition of the time and
timezone id fill in some missing details for the start and end times.
The additonal reformats improve readability.

Signed-off-by: Tony Germano <tony@germano.name>
Added 100% test coverage for

* `ContentSearchElement`
* `MetaDataSearchElement`
* `MessageFilterToStringStyle`
* `SearchElementToStringStyle`
* `ContentSearchElementToStringStyle`

Signed-off-by: Tony Germano <tony@germano.name>
Copilot AI changed the title [WIP] Fix log4j2.properties invalid line causing server startup failure Sanitize invalid Log4j charset property before server and CLI startup Mar 26, 2026
Copilot AI requested a review from mgaffigan March 26, 2026 22:30
Copy link
Copy Markdown
Owner

@mgaffigan mgaffigan left a comment

Choose a reason for hiding this comment

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

The line needing to be removed during the migration is "dir.logs = logs". I don't know if anything but server was affected. Please do not target the charset line and then review for spurious changes.

Copy link
Copy Markdown
Author

Copilot AI commented Mar 26, 2026

The line needing to be removed during the migration is "dir.logs = logs". I don't know if anything but server was affected. Please do not target the charset line and then review for spurious changes.

Updated in 8bf73db. I reverted the charset/CLI changes, restored the original shipped config entries, and changed the server-side startup sanitization to remove the legacy dir.logs property only. I also added a focused server launcher test to verify that dir.logs is removed without touching property.log.dir.

Copilot AI changed the title Sanitize invalid Log4j charset property before server and CLI startup Sanitize legacy dir.logs Log4j property before server startup Mar 26, 2026
Copilot AI requested a review from mgaffigan March 26, 2026 22:42
@mgaffigan mgaffigan force-pushed the copilot/fix-log4j2-properties-invalid-line branch 2 times, most recently from 0dc41ce to 2001324 Compare March 27, 2026 17:11
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2026

Test Results

  111 files  + 6    214 suites  +12   7m 2s ⏱️ + 1m 15s
  654 tests +21    654 ✅ +21  0 💤 ±0  0 ❌ ±0 
1 308 runs  +42  1 308 ✅ +42  0 💤 ±0  0 ❌ ±0 

Results for commit d17ee13. ± Comparison against base commit 346cc45.

♻️ This comment has been updated with latest results.

@mgaffigan mgaffigan force-pushed the copilot/fix-log4j2-properties-invalid-line branch from 2001324 to feb6b06 Compare March 27, 2026 17:28
Fixes a crash on boot caused by dir.logs set in log4j2.properties, which
is not supported in log4j2.  Cannot use normal migration infra since
log4j is initialized early in the boot processs (before classpath is
fully set up).

Issue: OpenIntegrationEngine#267
Signed-off-by: Mitch Gaffigan <mgaffigan@users.noreply.github.com>
@mgaffigan mgaffigan force-pushed the copilot/fix-log4j2-properties-invalid-line branch 2 times, most recently from bbf0117 to 71a5c24 Compare March 27, 2026 17:37
Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net>
@mgaffigan mgaffigan force-pushed the copilot/fix-log4j2-properties-invalid-line branch from 71a5c24 to d17ee13 Compare March 27, 2026 17:42
@mgaffigan mgaffigan closed this Mar 27, 2026
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.

3 participants