Enabling Mapped Diagnostic Context for Policy Editor logs
You can enable Mapped Diagnostic Context (MDC) in the default Policy Editor logs for enhanced visibility of application behavior.
About this task
MDC is a map of key-value pairs that you can use to enrich log messages. This can help when correlating log messages to a specific decision request. For example, if you want to correlate an HTTP service call recorded in the application logs to the decision request that invoked that service, you can use the decisionRequestId
generated by MDC.
MDC log data is enabled by default in the File-based Trace Log Publisher in embedded policy decision point (PDP) mode. |
The following table outlines the MDC keys available for each decision request type:
Decision request type | Key | Description |
---|---|---|
Individual requests |
|
Unique ID for the decision request. |
Batch requests |
|
Unique ID for the batch request. |
|
Unique ID for an individual decision request in the batch. |
|
Policy query requests |
|
Unique ID for the policy query request. |
|
Unique ID for an individual decision request in the query request. |
Steps
-
Stop the Policy Editor.
$ bin/stop-server
-
In the
PingAuthorize-PAP/config/configuration.yml
file, add the%mdc
configuration option to thelogFormat
field of the application logappenders
section:appenders: - type: "console" threshold: "INFO" target: "stdout" logFormat: "%-5level [%date{ISO8601}] %c, %mdc: %msg%n" - type: "file" threshold: "DEBUG" currentLogFilename: "logs/debug.log" maxFileSize: "250MB" archive: true archivedLogFilenamePattern: "logs/debug.%i.log.gz" archivedFileCount: 10 logFormat: "%-5level [%date{ISO8601}] [%thread] %c, %mdc: %msg%n" - type: "file" threshold: "INFO" currentLogFilename: "logs/authorize-pe.log" maxFileSize: "250MB" archive: true archivedLogFilenamePattern: "logs/authorize-pe.%i.log.gz" archivedFileCount: 10 logFormat: "%-5level [%date{ISO8601}] %c,%mdc: %msg%n"
-
Save your changes and restart the Policy Editor.
$ bin/start-server