Liberty Log Rotation Configuration Guide | Generated by AI

Home 2025.09

Here’s the short version, then examples you can paste into server.xml.

How Liberty log rotation works


Common server.xml recipes

1) Size-based rotation (classic)

Keeps up to 10 files, each up to 256 MB.

<logging
  logDirectory="${server.output.dir}/logs"
  maxFileSize="256"
  maxFiles="10"/>

Effect: when messages.log or trace.log exceeds 256 MB, Liberty rolls it to a timestamped file and keeps at most 10 such files. (Doesn’t affect console.log.) (openliberty.io)

2) Time-based rotation (e.g., daily at midnight)

<logging
  rolloverStartTime="00:00"
  rolloverInterval="1d"/>

Effect: messages.log and trace.log roll over every day at 00:00. You can use minutes (m) or hours (h) too, e.g., 30m or 6h. (openliberty.io)

3) Combine size + time (typical production)

<logging
  logDirectory="${server.output.dir}/logs"
  maxFileSize="256"
  maxFiles="14"
  rolloverStartTime="00:00"
  rolloverInterval="1d"/>

Effect: roll over whichever comes first (size or schedule), and keep a 14-file history. (IBM)

4) Tame or disable console.log growth

console.log can’t rotate; reduce or turn it off and rely on messages.log.

<logging
  consoleLogLevel="OFF"
  copySystemStreams="false"/>

Notes: turning console off stops Liberty’s own log copy to console.log, but the JVM may still write things like -verbose:gc to stdout/stderr. (openliberty.io)

5) Name/format tweaks (optional)

<logging
  messageFileName="messages.log"
  traceFileName="trace.log"
  messageFormat="JSON"/>

JSON is handy for shipping to a log stack; leave defaults if you don’t need it. (openliberty.io)


HTTP access log (separate from the above)

Enable access logging and roll it daily at midnight:

<httpAccessLogging id="accessLogging"
  rolloverStartTime="00:00"
  rolloverInterval="1d"/>

<httpEndpoint id="defaultHttpEndpoint"
  httpPort="9080" httpsPort="9443"
  accessLoggingRef="accessLogging"/>

(Or put rolloverStartTime/rolloverInterval directly on an <accessLogging …/> child of httpEndpoint.) (openliberty.io)


Quick checklist

If you share your current server.xml snippet or your retention goals (e.g., “keep ~7 days” or “cap at 2 GB”), I’ll tailor the exact values.


Back Donate