Enable and configure structured logging

To enable structured logging, set the serverlog.file.N configurable to the name of the file. The value you specify for N cannot exceed 500.

Enabling all structured logging files can consume considerable amounts of disk space. To manage the size of the log file and the number of log rotations, see Structured logfile rotation.

Names of the structured logs

Valid names for structured log files and the information logged are shown in the following table. You can use a file path in conjunction with the file name.

Warning

You must use one of the file names specified in the table. If you use an arbitrary name, no data will be logged to the file you specify.

Valid File Name Description

all.csv

All loggable events (commands, errors, audit, triggers, and more)

audit.csv

Audit events (audit, purge)

auth.csv

The results of p4 login attempts. If the login failed, the reason for this is included in the log. Additional information provided by the authentication method is also included.

commands.csv

Command events (command start, compute, and end)

errors.csv

Error events (errors-failed, errors-fatal)

events.csv

Server events (startup, shutdown, checkpoint, journal rotation, etc.)

integrity.csv

Major events that occur during replica integrity checking.

ldapsync.csv

p4 ldapsync events, such as when:

  • a user is added, updated, or removed
  • a user is added or removed from a group

route.csv

Log the full network route of authenticated client connections. Errors related to net.mimcheck are also logged against the related hop.

track.csv

Command tracking (track-usage, track-rpc, track-db)

triggers.csv

Trigger events.

user.csv

User events: one record every time a user runs p4 logappend.

Structured Log Configuration

Use p4 configure set to configure the log file name and optionally auto-rotation and retention policies. For example, to set up an errors.csv structured log to auto-rotate when it reaches 100MB and to retain the last 10 logs:

p4 configure set servername#serverlog.file.1=errors.csv

p4 configure set servername#serverlog.maxmb.1=100

p4 configure set servername#serverlog.retain.1=10

Auto-rotation and retention policies are optional but recommended to manage the size of structured logs. If you do not specify a servername with your p4 configure set command, the configurable is set for all servers in a Helix Core distributed environment. This includes edge and replica servers unless they override the global configuration with their own configurable setting.

Structured log files are automatically rotated on checkpoint, journal rotation, overflow of associated serverlog.maxmb.N limit if configured, and the p4 logrotate command. To disable structured log rotation after checkpoint or journal rotation, set the dm.rotatelogwithjnl configurable to 0.

The p4 -ztag logstat -s command is used to provide a summary of the configured structured logs. The configuration of structured logs is dynamic. After p4 configure set is run, no server restart is required and the server generates the log and starts using it when it processes the next server command. The name of a structured log automatically configures the events that log will capture.

Setting files

Files do not have to be set in consecutive order:

$ p4 configure set serverlog.file.1=audit.csv
$ p4 configure set serverlog.file.2=auth.csv
$ p4 configure set serverlog.file.4=track.csv
$ p4 configure set serverlog.file.3=triggers.csv