Enable and configure structured logging
To enable structured logging, set the serverlog.file.N configurable to the name of the file.
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.
The value you specify for N
cannot exceed
500.
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.
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.
Filename | Description |
---|---|
|
All loggable events (commands, errors, audit, triggers, and more) |
|
Audit events (audit, purge) |
|
The results of |
|
Command events (command start, compute, and end) |
|
Error events (errors-failed, errors-fatal) |
|
Server events (startup, shutdown, checkpoint, journal rotation, etc.) |
|
Major events that occur during replica integrity checking. |
ldapsync.csv |
p4 ldapsync events, such as when:
|
|
Log the full network route of authenticated client connections.
Errors related to |
|
Command tracking (track-usage, track-rpc, track-db) |
|
Trigger events. |
|
User events; one record every time a user runs |
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.rotatelogwithinjnl 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.
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