Skip to content

Feature request: Add TenantId to Logger default properties #2348

@phipag

Description

@phipag

Use case

With the new Lambda Tenant Isolation feature, we have access to the TenantId from the LambdaContext object.
We should add the TenantId to the default properties in the Logging utility.

https://docs.aws.amazon.com/lambda/latest/dg/tenant-isolation.html

Solution/User Experience

We need to add support for both logging backends, log4j2 and logback. The outcome should be that (without the user changing any code) the emitted JSON will contain tenant_id.

{
    "level": "Information",
    "message": "User object: Doe, John (42)",
    "timestamp": "2025-04-07 09:06:30.708",
    "service": "user-service",
    "coldStart": true,
    "name": "...",
    "user": {
        "firstName": "John",
        "lastName": "Doe",
        "age": 42
    },
    ...
    "tenantId": "cff02b3a-0e12-4be2-b3e0-758b49c4cd9b"
    ...
}

Implementation suggestion

For Log4j2:

For Logback:

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions