Configure logging

Administrators can configure several types of logging to help monitor server activity, troubleshoot issues, and meet auditing requirements.

P4 Server supports the following logging options:

  • Standard log (P4LOG) - Records server events and errors in a human-readable format. See Standard log file

  • Audit log (P4AUDIT) - Records user file access for auditing purposes. See Audit log file

  • Structured logs - Provide detailed operational and performance data in a machine-readable format for analysis and integration with monitoring and observability tools. See Structured logs.

For information about logging concepts, monitoring, log analysis, and selecting the appropriate logging mechanism for your environment, see Logging.

Standard log file

The standard log P4 Server supports the standard log, which is human-readable, as well as structured logs in a comma-separated value (CSV) format. The P4LOG environment variable specifies the log file for events, including errors. The human-readable P4AUDIT environment variable specifies the log file that records file transfers to users. Structured log files are typically processed by external tools. To learn more, see 'Logging" in P4 Server Administration Documentation. file records server events and might include records of errors.

Use the -L flag to p4d or the P4LOG environment variable to specify the standard log file.

If no error output file is defined, errors are written to the standard error stream of the p4d process. Although p4d attempts to ensure that all error messages reach the user, errors are also written to the error output if a user application disconnects before receiving the message.

For information about logging levels and detailed server activity, see Using P4LOG.

P4 Server also supports trace flags used for debugging. To learn more, see Diagnostic flags for monitoring the server.

Audit log file

If your site requires user file access to be tracked, use the -A flag to p4d or the P4AUDIT environment variable to enable auditing and specify the audit log file.

When auditing is enabled, a record is stored each time a user accesses a file. On busy servers, audit logs can consume considerable disk space.

To learn more, see Auditing user file access.

Structured logs

Structured logs record detailed operational and performance information in a machine-readable format that can be analyzed using reporting, monitoring, and observability tools.

For information about configuring and using structured logs, see:

Manage growth of log files

The log files defined by P4LOG and P4AUDIT continually grow.

P4 Server can reject commands when free disk space falls below configured limits. To learn more, see Monitor disk space usage.

To help manage log file growth:

  • Use a script or scheduled task to rotate, rename, or archive log files.

  • Follow your organization's retention policies for historical log data.

When the P4LOG or P4AUDIT log files are renamed or moved, P4 Server automatically creates a new log file in the original location.