Skip to content

Logger category is silently dropped in JSON log format (IncludeCategory has no effect) #2469

Description

@madmox

Describe the bug

With Amazon.Lambda.Logging.AspNetCore, the ILogger category name is included in log output in plain-text mode (governed by LambdaLoggerOptions.IncludeCategory), but in JSON log format the category is dropped entirely: the JSON branch of LambdaILogger.Log only forwards the message template and arguments, and JsonLogMessageFormatter has no category concept either. IncludeCategory = true is silently ignored.

The category is the primary key for locating and filtering .NET logs ("which class/middleware emitted this?"). After switching a function from text to JSON log format, CloudWatch Logs Insights queries can no longer filter on it, and log lines can only be traced back to their source by searching for the literal message text.

Regression Issue

  • Select this option if this issue appears to be a regression.

(Behavioral regression when migrating a function from text to JSON log format: the category was present in every text log line, and there is no way to opt back into it.)

Expected Behavior

The logger category available in JSON records — ideally as a dedicated property, e.g.:

{
    "timestamp": "2026-07-04T22:43:57.529Z",
    "level": "Information",
    "category": "MyApp.Filters.IdentityValidatorActionFilter",
    "message": "Successfully authenticated user"
}

Current Behavior

{
    "timestamp": "2026-07-04T22:43:57.529Z",
    "level": "Information",
    "message": "Successfully authenticated user"
}

No trace of the category anywhere in the record, regardless of LambdaLoggerOptions.IncludeCategory.

Reproduction Steps

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi);
builder.Logging.ClearProviders();
builder.Logging.AddLambdaLogger();
var app = builder.Build();
app.MapGet("/", (ILogger<Program> logger) =>
{
    logger.LogInformation("Hello from a categorized logger");
    return "ok";
});
app.Run();

Deploy with LoggingConfig.LogFormat: JSON, invoke /, and observe that the record contains no Program/category information, while the same app with text log format produces info: Program[0] Hello from a categorized logger.

Possible Solution

Emit the category as a top-level JSON property ("category"), or at minimum honor IncludeCategory by prefixing the rendered message.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.AspNetCoreServer 10.1.1
Amazon.Lambda.AspNetCoreServer.Hosting 2.1.0
Amazon.Lambda.Logging.AspNetCore 5.0.0
Amazon.Lambda.Core 3.1.0

Targeted .NET Platform

.NET 10 (managed dotnet10 runtime)

Operating System and version

Amazon Linux 2023 (Lambda managed runtime)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions