Verify JRE Java SDK events

An event moves through four stages between your logEvent() call and Amplitude's servers. Verify each stage in order. The first stage where the event looks wrong is where the problem is.

For problems common to every Amplitude SDK, go to SDK troubleshooting and debugging. If behavior changed after an SDK upgrade, check the Java SDK changelog.

Turn on debug logging

Set the log level to DEBUG while you verify.

java
Amplitude client = Amplitude.getInstance();
client.init("AMPLITUDE_API_KEY");
client.setLogMode(AmplitudeLog.LogMode.DEBUG);

client.logEvent(new Event("Sign Up Completed", "user-12345"));

The SDK logs only when it uploads or retries events. It prints nothing when you call logEvent(). Each message has the form <tag>: <message>. DEBUG and WARN messages go to standard output, and ERROR messages go to standard error.

A successful upload logs this:

text
SEND: Events count 1
RESPONSE: {
    "code": 200,
    "successBody": {
        "serverUploadTime": 1794340064240,
        "payloadSizeBytes": 412,
        "eventsIngested": 1
    },
    "status": "SUCCESS"
}

The SDK doesn't log the API key. Error event payload lines contain event data, so return the level to ERROR before you deploy.

Check what the SDK captured

The SDK has no log for logEvent(). To see each event as logEvent() receives it, add a middleware that prints it and passes it on:

java
Amplitude client = Amplitude.getInstance();
client.init("AMPLITUDE_API_KEY");

client.addEventMiddleware((payload, next) -> {
  System.out.println("Amplitude event: " + payload.event);
  next.run(payload);
});

Event event = new Event("Sign Up Completed", "user-12345");
event.addEventProperty("plan", "starter");
client.logEvent(event);

The middleware prints the event as JSON, with the same fields the SDK uploads:

json
{
  "event_type": "Sign Up Completed",
  "user_id": "user-12345",
  "device_id": null,
  "event_properties": { "plan": "starter" },
  "user_properties": {},
  "groups": {},
  "group_properties": {},
  "session_id": -1,
  "event_id": 0,
  "location_lat": 0,
  "location_lng": 0,
  "library": "amplitude-java/1.13.1"
}

Check the output for these problems:

Check how middleware transformed the event

Middleware runs in the order you added it. To see the event after your other middleware changed it, add the inspection middleware last. A middleware that doesn't call next.run(payload) drops the event: it never reaches the queue, and no callback runs for it.

The SDK adds no fields in middleware. Before the first middleware runs, it adds the instance's Plan and IngestionMetadata to events that have none. It adds library when it builds the upload.

Check what the SDK sent

A server process has no Network tab. The upload body is a JSON object with api_key, events (each event's toJsonObject()), and options when you set Options. The SDK doesn't compress it.

  • Count: at DEBUG level, SEND: Events count N confirms that an upload ran and how many events it held.
  • Content: the inspection middleware prints what each event contributes to the body.
  • Raw request: the SDK sends only over HTTPS, so a plain local HTTP server can't receive it. Run an intercepting HTTPS proxy, point the SDK at it with setProxy(), and add the proxy's certificate to the JVM's trust store.

If no SEND line appears, the upload didn't run. The usual cause is a program that ends before the next scheduled upload. Go to Flush and shut down.

Check what Amplitude received

Read the upload result

The SDK reports the result for each event to callbacks. Set a callback while you verify:

java
Amplitude client = Amplitude.getInstance();
client.init("AMPLITUDE_API_KEY");
client.setCallbacks(new AmplitudeCallbacks() {
  @Override
  public void onLogEventServerResponse(Event event, int status, String message) {
    System.out.println(event.eventType + ": " + status + " " + message);
  }
});

client.logEvent(new Event("Sign Up Completed", "user-12345"));

A successful upload prints Sign Up Completed: 200 Event sent success.

Events dropped by middleware, and events still in the queue when you call shutdown() without flushEvents(), get no callback.

Find the event in Amplitude

  1. In Amplitude, open User Lookup and search for the user ID or device ID of the event.
  2. Open the Activity tab and turn on Live event updates.
  3. Confirm that the event appears with the properties you set.

If the callback reported 200 but the event doesn't appear, check that the API key belongs to the project you're looking at, and that the server URL matches the project's data center.

Was this helpful?

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

On this page