Knowledge base

PMTA knowledge base›Block Global›Directive§ 3.3.1.59.3

log-rotate

Global

How many log files to keep during rotation
in the configuration this is a linelog-rotate 8inside the block Global
The depth of log history

During rotation the engine renames old files, appending a number: on Unix log becomes log.1, log.1 becomes log.2 and so on — and then starts a new one. The line sets how many files to keep in total. The default is 8.

The number includes the current file. The value 1 means “only the current one, no history,” 2 means the current one plus one old one. 0 turns rotation off entirely, and the file will grow without limit.

Rotation can be triggered by hand — with the pmta rotate log command. This is useful before handing the log to support: the current file is closed and can be taken in full.

Automatic rotation happens at midnight, and it is controlled by the neighboring line log-auto-rotation.

The main trap is thinking these are days. This is the number of files, not a period. How many days fit into eight files depends on how often they are switched — that is, on log-auto-rotation and on how fast the log grows.
What the Hub does. It does not write it — the log is looked after by the system logrotate in our setup, as a comment in the template next to log-file says.

So the vendor default of 8 applies, and two rotations — the built-in one and the system one — run at the same time. This does not break anything by itself, but it is worth remembering: there may be more numbered files than expected.

Recommended values

The depth is chosen by how long the history is needed:

Value What it means
8 (default) the current one plus seven old ones
1 only the current one, no history
0 no rotation at all, the file grows without limit

These are files, not days. The period depends on the switching frequency.

The 8 default, the numbering rule, the current file counting toward the total, turning it off with zero and the manual log switching command come from the manual (§ 3.3.1.59.3). The note about coexisting with system rotation is ours.
Example configuration
# the current file plus seven old ones
log-file /var/log/pmta/log
log-rotate 8
The value 0 is dangerous here: the file will grow until the partition runs out of space — and accounting and possibly the spool live on the same partition.
yellow — — directive names, blue — blocks. They are highlighted the same way in the text of the card.
▲

Common mistakes and problems

what people get wrong and how it ends2 mistakes▶

Setting 0 so as “not to lose history”

our experience

What it costsRotation turns off entirely, and the file grows without limit. The partition with the log usually holds accounting too — both will run out of space at once.
How to spot itA single log file of several gigabytes.
How to do it rightKeep rotation on, and move history elsewhere as a separate task.

Taking the value for a retention period

our experience

What it costsIt is a number of files. With frequent switching eight files may cover a day, with rare switching a month. Investigations cannot be planned by this number.
How to spot itThe needed day is not in the logs, although “eight are kept.”
How to do it rightLook at the file dates rather than their count; increase the value if necessary.
Compatibility
PowerMTA 6.0
described in the manual of this version · platform: any
The vendor does not state the first version for every directive — there is no note here. The name also appears in the 5.0 edition of the manual.
Reference data
Syntax
log-rotate <number>
Values
an integer; 0 turns rotation off
Default
8 § 3.3.1.59.3
Applying
reload, no restart needed
Queue
will not touch what is already queued
Where to write it
Global
How many times
once in the block
Everything here comes from the manual, with the section.
Inheritance
There is no inheritance: the line is written at the root of the file, in the Global section, and concerns the node log. Accounting files have their own rotation — move-interval, max-size and delete-after in the <acct-file> block.
How to check on the node
The check is direct — we count the log files:
ls -la /var/log/pmta/log*
There should be no more files than the set number, including the current one. More means system rotation is also running alongside, and it is worth choosing just one.
In the Hub
Cost of a mistake
safe: a wrong value breaks nothing
Scenarios
Untangle a stuck queue