Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions docs/advanced/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,48 @@ Logs include execution context via MDC (works with any SLF4J-compatible logging
{
"timestamp": "2024-01-15T10:30:00.000Z",
"level": "INFO",
"message": "Processing order: ORD-123",
"durableExecutionArn": "arn:aws:lambda:us-east-1:123456789:function:order-processor:exec-abc123",
"message": "Validating order details",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_xidywmll6dim2soxj2rxpshvga

The sample now uses the step lambda's Validating order details message, but the Basic Usage example emits it with debug() while the JSON still labels it INFO. Change the JSON level to DEBUG (or change the usage call to info()) so the documented output can actually result from the shown code.

"executionArn": "arn:aws:lambda:us-east-1:123456789:function:order-processor:exec-abc123",
"requestId": "a1b2c3d4-5678-90ab-cdef-example12345",
"operationId": "1",
"operationName": "validate"
"operationName": "validate",
"attempt": "1"
}
```

Java SDK 2.x uses `executionArn`, `operationId`, and `operationName` by default.
Applications migrating log queries or dashboards from 1.x can temporarily emit
`durableExecutionArn`, `contextId`, and `contextName` instead:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_ewlk5oveokuvpuhmprfzmfnjv2

oldKeyNames=true does not replace operationId or operationName on StepContext logs; those keys are always emitted, while only the ARN key changes. Since the preceding example is a step log, this may lead users to query for fields that never appear. Clarify that contextId/contextName apply to durable child-context logs and that step logs retain operationId/operationName.


```java
@Override
protected DurableConfig createConfiguration() {
return DurableConfig.builder()
.withLoggerConfig(new LoggerConfig(true, true))
.build();
}
```

The first argument controls replay suppression. The second enables the old MDC key
names.

### Custom SLF4J Delegate

`getLogger()` uses the SDK's default SLF4J logger. Pass a specific SLF4J `Logger` to
`getLogger(Logger delegate)` when you want the durable metadata and replay behavior
applied to another logger:

```java
private static final Logger applicationLogger =
LoggerFactory.getLogger(OrderProcessor.class);

var logger = ctx.getLogger(applicationLogger);
logger.info("Processing order: {}", order.getId());
```

This creates a `DurableLogger` around the supplied delegate for that call. It does not
replace the default returned by later parameterless `getLogger()` calls.

### Replay Behavior

By default, logs are suppressed during replay to avoid duplicates:
Expand All @@ -59,4 +93,4 @@ protected DurableConfig createConfiguration() {
.withLoggerConfig(LoggerConfig.withReplayLogging())
.build();
}
```
```
Loading