Skip to content

[Server] Keep days of server log history with the default log config - #2056

Merged
yili-db merged 2 commits into
unitycatalog:mainfrom
NopeCharon:fix-server-log-retention
Oct 28, 2026
Merged

yili-db merged 2 commits into
unitycatalog:mainfrom
NopeCharon:fix-server-log-retention

Conversation

@NopeCharon

@NopeCharon NopeCharon commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests! (config-only change, verified by hand as described below)
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Closes #2055.

With the shipped etc/conf/server.log4j2.properties, a server that logs steadily keeps only about 5 seconds of history. The archive pattern ends in seconds (%d{MM-dd-yyyy-HH-mm-ss}), and TimeBasedTriggeringPolicy rolls over on the most specific unit of the date pattern, so interval = 1 meant one archive per second. IfAccumulatedFileCount then kept only the newest 5 archives. Startup lines, and the 5xx ERROR line #1999 added, were deleted within seconds.

Changes to etc/conf/server.log4j2.properties:

  • The archive pattern is now server-%d{yyyy-MM-dd-HH}-%i.log.gz, so the log rolls over hourly. The 10MB size trigger still splits a busy hour into -1, -2, ... archives, and archive names now sort by date.
  • Archives are deleted by age and total size, not by count: IfLastModified with P7D, ORed with IfAccumulatedFileSize over 1GB, replaces IfAccumulatedFileCount. The IfFileName glob is unchanged, so archives left over in the old naming scheme also age out after 7 days.
  • strategy.max goes from 5 to 20, so an hour that logs more than 50MB no longer overwrites its own oldest archives.

docs/server/configuration.md now describes the default rolling and retention.

Compatibility: only the default config file changes. Archive names change format, and archives are no longer capped at 5 files, so disk use is bounded by 7 days of logs or 1GB of archives, whichever is smaller. The Helm chart renders its own console-only config and is not affected.

Validation: I ran a small program against log4j-core 2.26.1, the version the server uses, with the old and the new config file:

  • One line every 250ms for 8 seconds. With the old config, etc/logs ended up with 4 per-second archives, and server.log started at line 28. With the new config, no archive was created and server.log held every line from line 0.
  • With the new config, a 25MB burst, starting with an archive last modified 8 days ago, one modified 6 days ago, and an unrelated other.log in etc/logs. The burst rolled over twice, to server-2026-10-26-10-1.log.gz and -2.log.gz. The 8-day-old archive was deleted, and the 6-day-old archive and other.log were kept. Log4j printed no status warnings for the config.

The shipped etc/conf/server.log4j2.properties named archives
server-%d{MM-dd-yyyy-HH-mm-ss}-%i.log.gz. TimeBasedTriggeringPolicy rolls
over on the most specific unit of that date pattern, seconds, so a server
that logs steadily wrote one archive per second, and the
IfAccumulatedFileCount condition then kept only the newest 5. Startup lines
and the ERROR line of a failed request were gone within seconds.

- Name archives server-%d{yyyy-MM-dd-HH}-%i.log.gz, so the log rolls over
  hourly (the 10MB size trigger still splits a busy hour) and archive names
  sort by date.
- Delete archives by age instead of by count: IfLastModified P7D replaces
  IfAccumulatedFileCount, so archives last written more than 7 days ago are
  deleted at the next rollover. The IfFileName glob is unchanged, so
  archives in the old naming scheme age out the same way.
- Raise the DefaultRolloverStrategy max from 5 to 20, so an hour that logs
  more than 50MB no longer overwrites its own oldest archives.
- Describe the default rolling and retention in docs/server/configuration.md.

Fixes unitycatalog#2055

Signed-off-by: NopeCharon <[email protected]>
@yili-db

yili-db commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] LGTM, thanks for the careful validation against log4j-core. The hourly pattern plus IfLastModified next to IfFileName is correct (top-level Delete conditions are ANDed), and old-format archives still match the glob and age out. One question on a size cap and a docs nit inline, neither blocking.

Comment thread etc/conf/server.log4j2.properties Outdated
appender.rollingFile.strategy.action.ifAny.type = IfAccumulatedFileCount
appender.rollingFile.strategy.action.ifAny.exceeds = 5
appender.rollingFile.strategy.action.age.type = IfLastModified
appender.rollingFile.strategy.action.age.age = P7D

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] With the count cap gone, retention is bounded only by age. Worst case is 20 x 10MB per hour for 7 days, a few GB once gzipped. Should we also cap total size, ORed with the age limit? Nesting under IfFileName keeps only server-*.log.gz counted toward the cap, regardless of condition order:

appender.rollingFile.strategy.action.condition.type = IfFileName
appender.rollingFile.strategy.action.condition.glob = server-*.log.gz
appender.rollingFile.strategy.action.condition.any.type = IfAny
appender.rollingFile.strategy.action.condition.any.age.type = IfLastModified
appender.rollingFile.strategy.action.condition.any.age.age = P7D
appender.rollingFile.strategy.action.condition.any.size.type = IfAccumulatedFileSize
appender.rollingFile.strategy.action.condition.any.size.exceeds = 1GB

Delete visits newest first, so this keeps the newest 1GB; at normal volume the 7 days still applies. If you add it, a rerun of your burst check with a small exceeds would confirm the size branch, and the docs paragraph should mention the cap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added it as you suggested, with IfLastModified P7D and IfAccumulatedFileSize 1GB under IfAny nested in IfFileName, and the docs mention the cap. Reran the burst check with exceeds = 12MB: only the newest ~10.8MB of archives were kept and other.log was untouched (d85124b).

Comment thread docs/server/configuration.md Outdated
file: `etc/conf/server.log4j2.properties`.

With the default log4j2 config, the log rolls over every hour, and within an hour each time it reaches 10MB. Each
rolled-over file is compressed into `etc/logs/server-<yyyy-MM-dd-HH>-<n>.log.gz`. At each rollover, archives last

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] nit: maybe say what <n> is, e.g. a per-hour index starting at 1, at most 20 per hour.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, the docs now say <n> numbers the archives of that hour, starting at 1, up to 20.

…e index

Delete server-*.log.gz archives that are older than 7 days or that fall
outside the newest 1GB of archives, so a busy server cannot fill the disk
within the age window. Explain the per-hour archive index in the docs.

Signed-off-by: NopeCharon <[email protected]>
@yili-db
yili-db merged commit d2b0a32 into unitycatalog:main Oct 28, 2026
16 checks passed
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.

[Server] Default log config keeps only about 5 seconds of server log history

2 participants