Managing Log Rotation Print

  • 0

Stopping logs filling the disk.

WHAT ROTATION DOES

Renames the current log, starts a new one, compresses old ones, and deletes the oldest.

WHY IT IS NECESSARY

Logs grow without limit, and a full disk stops everything.

WHERE IT IS CONFIGURED

A main configuration file, plus one file per service in a directory.

WHAT THE KEY SETTINGS ARE

How often to rotate How many to keep Whether to compress What to do after rotating

WHAT THE POST-ROTATE STEP IS FOR

Telling the service to reopen its log file.

WHY THAT MATTERS

Without it the service keeps writing to the renamed file, and the new one stays empty.

WHAT THAT LOOKS LIKE IN PRACTICE

A compressed old log that keeps growing, and a current log of zero bytes.

WHAT TO PREFER WHERE SUPPORTED

Copying and truncating, which avoids the problem entirely.

HOW TO TEST A CONFIGURATION

Run rotation in debug mode, which reports what it would do.

WHY TEST

An error in one file can stop rotation for everything.

WHAT TO CHECK PERIODICALLY

That rotation is actually running That old logs are being removed

WHAT TO WATCH FOR

Application logs outside the system's rotation, which are frequently forgotten.

WHAT TO DO ABOUT A LOG ALREADY ENORMOUS

Truncate it rather than deleting it, if the service holds it open.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot