Enable and configure structured logging
To enable structured logging, set the serverlog.file.N configurable to the name of the file. For example, set the serverlog.file.20 configurable to file-name.csv on the server named server-id:
p4 configure set server-id#serverlog.file.20=file-name.csv
The value you specify for N (20 in the previous example) cannot be greater than 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.
On this page:
Structured log formats
The structured log file should be .csv or .json format. If you attempt to use a different file format, the file will be converted to .csv.
Structured log names
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.
| File name | 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 |
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 server-id#serverlog.file.1=errors.csv
p4 configure set server-id#serverlog.maxmb.1=100
p4 configure set server-id#serverlog.retain.1=10
Files do not have to be set in consecutive order.
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 P4 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.