Knowledge base

PMTA knowledge base›Block Global›Directive§ 3.3.1.59.2

log-file

Globalset by the Hub

Where the engine log lives
in the configuration this is a linelog-fileinside the block Global
The only mandatory log line

The line sets the path to the log file. The manual calls it mandatory: it must always be present in the configuration. On Unix the path must be absolute.

One line sets three files. Besides the engine’s own log, it determines the location of the web monitor log (pmtahttp.log) and the SNMP log. This is worth remembering when looking for where the monitor’s records went: they are nearby, but in another file.

The log and accounting are different things, and the separation is deliberate (§ 4.1.2). The log answers the question “what did the node do”: start, stop, errors, connection traces. Accounting — “what happened to the messages.” The first place to look for any malfunction is the log.

The engine writes to the operating system log only what it could not write here — startup errors and similar cases. If the file is unavailable, that is where to look.

The main trap is looking for web monitor records in the engine log. Access refusals, handshake progress and calls to the HTTP interfaces are in pmtahttp.log next to it. The line gives them a common directory, but not a common file.
What the Hub does. It writes /var/log/pmta/log, and next to it in the template there is a comment “rotation — logrotate.”

🔎 That is, we do not use the engine’s built-in rotation. Neither log-rotate nor log-auto-rotation is in our configuration, and the file is handled by the system’s logrotate. This is a working solution, but it has a cost: the engine keeps the file open, and the rotation rule must either copy and truncate or send the engine a signal — otherwise it will keep writing to the deleted file.

Recommended values

The path is chosen where the system’s other logs are:

Value Note
/var/log/pmta/log our choice; the monitor and SNMP logs will go next to it
a relative path only on Windows

The line has no default — the manual requires it to always be set.

The line being mandatory, the requirement of an absolute path on Unix and the fact that it also sets the monitor and SNMP logs come from the manual (§ 3.3.1.59.2). The separation of log and accounting comes from § 4.1.2. The analysis of our rotation is based on the Hub template.
Example configuration
# one line sets three files: the engine's, the monitor's and SNMP's
log-file /var/log/pmta/loglog-rotate 8
The second line is optional, but without it the file size has to be watched by something else — system rotation, for example, as we do.
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▶

Looking for information about messages in the engine log

§ 4.1.2

What it costsThe log tells what the node did, not what happened to a message. Delivery history is in accounting, and the separation is deliberate.
How to spot itThe log has not a single line about a specific message, even though it was sent.
How to do it rightLook at the accounting file; make the log more verbose only to investigate a connection.

Setting up rotation in the system without telling the engine

our experience

What it costsThe engine keeps the file open. If the rotation rule simply renames and deletes the file, the engine will keep writing to the vanished one — and there will be records neither in the old file nor in the new one.
How to spot itAfter rotation the log is empty and does not grow, while the disk space is still taken.
How to do it rightEither copy and truncate (copytruncate), or send the engine a signal in the rotation rule, or use the built-in log-rotate rotation.
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-file FILENAME
Values
an absolute file path
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 sets the node’s only log. It cannot be split by source or block — verbosity is configured with switches like log-connections, but there is one file.
How to check on the node
We look at where the engine actually writes and what appears there:
grep -n '^log-file' /etc/pmta/config
ls -l /var/log/pmta/
If the file does not exist or is not being written, look for the cause in the operating system log — that is exactly where the engine reports such cases. Next to it there should be pmtahttp.log: it is about the monitor.
In the Hub
Managed at
Analytics → Node accounting
Value
The Hub picks it itself — pace, warm-up stage, metrics
Cost of a mistake
reversible: harms only while it is set
Scenarios
Prepare a node for sending · Untangle a stuck queue