Skip to content
Small Systems Notebook

Working notes on running small web services without drama.

Log rotation without surprises

Log rotation without surprises
Size limits, copytruncate, and why the daemon should be told.

Rotation by size catches the day when a client misbehaves and writes a gigabyte of errors in an hour. Rotation by time alone does not. A cap of a few files of a few megabytes each is plenty for a small service.

copytruncate is convenient but loses the lines written between the copy and the truncate. When the program can reopen its log on a signal, prefer that and send the signal from the rotation hook.

#ops#logging