Repository navigation
[Server] Keep days of server log history with the default log config - #2056
Conversation
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]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[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.
| 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 |
There was a problem hiding this comment.
[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 = 1GBDelete 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.
There was a problem hiding this comment.
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).
| 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 |
There was a problem hiding this comment.
[AI Assisted] nit: maybe say what <n> is, e.g. a per-hour index starting at 1, at most 20 per hour.
There was a problem hiding this comment.
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]>
PR Checklist
docsis updatedDescription 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}), andTimeBasedTriggeringPolicyrolls over on the most specific unit of the date pattern, sointerval = 1meant one archive per second.IfAccumulatedFileCountthen kept only the newest 5 archives. Startup lines, and the 5xxERRORline #1999 added, were deleted within seconds.Changes to
etc/conf/server.log4j2.properties: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.IfLastModifiedwithP7D, ORed withIfAccumulatedFileSizeover1GB, replacesIfAccumulatedFileCount. TheIfFileNameglob is unchanged, so archives left over in the old naming scheme also age out after 7 days.strategy.maxgoes from 5 to 20, so an hour that logs more than 50MB no longer overwrites its own oldest archives.docs/server/configuration.mdnow 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:
etc/logsended up with 4 per-second archives, andserver.logstarted at line 28. With the new config, no archive was created andserver.logheld every line from line 0.other.loginetc/logs. The burst rolled over twice, toserver-2026-10-26-10-1.log.gzand-2.log.gz. The 8-day-old archive was deleted, and the 6-day-old archive andother.logwere kept. Log4j printed no status warnings for the config.