---
title: Auditing
description: Java Agent logs audit events for security, troubleshooting, and regulatory compliance. Logs are written in UTF-8. Store audit event logs in the following ways:
component: java-agents
version: 2023.11
page_id: java-agents:maintenance-guide:auditing
canonical_url: https://docs.pingidentity.com/java-agents/2026/maintenance-guide/auditing.html
llms_txt: https://docs.pingidentity.com/java-agents/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
superseded_by: https://docs.pingidentity.com/java-agents/2026/maintenance-guide/auditing.html
section_ids:
  configure_audit_logging: Configure audit logging
---

# Auditing

Java Agent logs audit events for security, troubleshooting, and regulatory compliance. Logs are written in UTF-8. Store audit event logs in the following ways:

* Remotely

  Log audit events to the audit event handler configured in the AM realm. In an environment with several AM servers, agents write audit logs to the AM server that satisfies the agent request for client authentication or resource authorization.

  Java Agent cannot log audit events remotely if:

  * AM's Audit Logging Service is disabled.

  * No audit event handler is configured in the realm where the agent is configured.

  * All audit event handlers configured in the realm where the agent is configured are disabled.

  For more information about audit logging in AM, refer to [Setting up audit logging](https://docs.pingidentity.com/pingam/7.4/security-guide/audit-logging.html) in AM's *Security guide*.

* Locally

  Log audit events in JSON format to a file in the agent installation directory, `/java_agents/agent_type/logs/audit/` .

* Remotely and locally

  Log audit events:

  * To a file in the agent installation directory.

  * To the audit event handler configured in the AM realm in which the agent profile is configured.

The following is an example of an agent log record:

```json
{
   "timestamp":"...",
   "eventName":"AM-ACCESS-OUTCOME",
   "transactionId":"608831c4-7351-4277-8a5f-b1a83fe2277e",
   "userId":"id=demo,ou=user,dc=openam,dc=forgerock,dc=org",
   "trackingIds":[
      "fd5c8ccf-7d97-49ba-a775-76c3c06eb933-82095",
      "fd5c8ccf-7d97-49ba-a775-76c3c06eb933-82177"
   ],
   "component":"Java Policy Agent",
   "realm":"/",
   "server":{
      "ip":"127.0.0.1",
      "port":8020
   },
   "client":{
      "ip":"127.0.0.1",
      "port":55180
   },
   "request":{
      "protocol":"HTTP/1.1",
      "operation":"GET"
   },
   "http":{
      "request":{
         "secure":false,
         "method":"GET",
         "path":"http://my.example.com:8020/examples/",
         "headers":{
            "referer":[
               "https://am.example.com:8443/am/oauth2/authorize?scope[...]"
            ],
            "accept-language":[
               "en,en-US;q=0.8,da;q=0.6,fr;q=0.4"
            ],
            "host":[
               "my.example.com:8020"
            ],
            "upgrade-insecure-requests":[
               "1"
            ],
            "connection":[
               "keep-alive"
            ],
            "cache-control":[
               "max-age=0"
            ],
            "accept-encoding":[
               "gzip, deflate"
            ],
            "user-agent":[
               "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko)[...]"
            ],
            "accept":[
               "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
            ]
         },
         "cookies":{
            "am-auth-jwt":"eyJ0eXAiOiJKV1QiLCJhbGciOi[...]"
            "i18next":"en",
            "amlbcookie":"01",
            "iPlanetDirectoryPro":"Ts2zDkGUqgtkoxR[...]"
         }
      }
   },
   "response":{
      "status":"DENIED"
   },
   "_id":"fd5c8ccf-7d97-49ba-a775-76c3c06eb933-81703"
}
```

|   |                                                                              |
| - | ---------------------------------------------------------------------------- |
|   | Local audit logs do not have an `_id` attribute, which is an internal AM id. |

The audit log format adheres to the log structure shared across the Ping Advanced Identity Software. For more information about the audit log format, refer to [Audit log format](https://docs.pingidentity.com/pingam/7.4/security-guide/sec-maint-audit-ref.html#audit-log-format) in AM's *Security guide*.

Java Agent supports propagation of the transaction ID across the Ping Advanced Identity Software, using the HTTP header `X-ForgeRock-TransactionId`. For more information about configuring the header, refer to [Configuring the trust transaction header system property](https://docs.pingidentity.com/pingam/7.4/security-guide/implementing-audit.html#configuring-trusttransactionheader-system-property) in AM's *Security guide*.

## Configure audit logging

By default, Java Agent does not write audit log records. To configure audit logging, perform this procedure. The agent in this example is in [remote configuration mode](../user-guide/glossary.html#def-remote-configuration-mode).

1. In the AM admin UI, select Realms > realm name > Applications > Agents > Java > agent name > Global > Audit.

2. In [Audit Access Types](../properties-reference/org.forgerock.agents.audit.what.html), select the type of messages to log. For example, select `LOG_ALL` to log access allowed and access denied events.

3. In [Audit Log Location](../properties-reference/org.forgerock.agents.audit.where.html), select whether to write the audit logs locally to the agent installation (`LOCAL`), remotely to AM (`REMOTE`), or to both places (`ALL`). For example, keep `REMOTE` to log audit events to the AM instances.

4. To log audit messages locally, enable [Enable Local Audit Log Rotation](../properties-reference/org.forgerock.agents.local.audit.log.rotation.enabled.html) to rotate the audit log files when they reach a maximum size.

5. If you enabled [Enable Local Audit Log Rotation](../properties-reference/org.forgerock.agents.local.audit.log.rotation.enabled.html), specify the maximum size of the audit log files in [Local Audit Log Rotation Size](../properties-reference/org.forgerock.agents.local.audit.log.rotation.bytes.html).
