---
url: /logly.zig/examples/distributed-json.md
description: Emit distributed trace context as JSON with Logly.zig trace and span IDs.
---

# Distributed JSON

Single JSON record with service identity and trace context.

```zig
var logger = try logly.Logger.init(allocator);
defer logger.deinit();

try logger.setTraceContext("trace-123", "span-456");
try logger.info("Test distributed log", @src());
```

Output:

```json
{
  "timestamp": "2026-10-07 05:57:18.979",
  "level": "INFO",
  "message": "Test distributed log",
  "service": "test-service",
  "traceId": "trace-123",
  "spanId": "span-456"
}
```
