pm3 logopm3

Logging

Log files, rotation, tailing, and timestamp formatting.

pm3 captures all process output into log files and provides tools for viewing, tailing, and managing them.

Log Files

Each process gets two log files:

FileContent
<name>-out.logStandard output (stdout)
<name>-err.logStandard error (stderr)

Log files are stored in ~/.local/share/pm3/logs/.

PTY Support

pm3 uses a PTY (pseudo-terminal) for child process stdout. This preserves line-buffered output behavior, ensuring logs appear immediately rather than being delayed by output buffering. Each line is flushed to disk immediately for real-time visibility.

Viewing Logs

Default (last 15 lines)

pm3 log web

Custom line count

pm3 log web --lines 50

Follow mode

pm3 log web -f

Streams new log lines in real-time, similar to tail -f. Press Ctrl+C to stop.

Clearing Logs

pm3 flush          # Clear all process logs
pm3 flush web api  # Clear specific process logs

Log Rotation

pm3 automatically rotates log files:

ParameterValue
Max file size10 MB
Rotated files kept3

When a log file exceeds 10MB, it's rotated and up to 3 old files are kept.

Timestamp Formatting

Customize log timestamps with the log_date_format option using strftime format strings:

[web]
command = "node server.js"
log_date_format = "%Y-%m-%d %H:%M:%S"

Common format specifiers:

SpecifierExampleDescription
%Y2025Four-digit year
%m03Two-digit month
%d15Two-digit day
%H1424-hour hour
%M30Minute
%S45Second
%T14:30:45Equivalent to %H:%M:%S
%F2025-03-15Equivalent to %Y-%m-%d

On this page