-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LoggingFormat=JSON does not affect exception logging #1831
Comments
@Dreamescaper Good morning. Thanks for opening the issue. Please let us know the following:
Thanks, |
I have a suspicion that this issue is already fixed, but is waiting for a managed runtime update on lambdas... I'll provide the info you're asking a bit later. |
@Dreamescaper The changes for structured logging would work as of now when using |
Are you deploying your function as an executable or class library? If you are deploying as an executable pulling in the latest versions of I'm assuming you are saying an exception that is thrown and not caught within your function handler. I just confirmed I got expected behavior with a function that does this: var handler = (string input, ILambdaContext context) =>
{
if (string.Equals(input, "fail", StringComparison.InvariantCultureIgnoreCase))
{
throw new ArgumentException("You said fail");
}
return input.ToUpper();
};
// Build the Lambda runtime client passing in the handler to call for each
// event and the JSON serializer to use for translating Lambda JSON documents
// to .NET types.
await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync(); And get the following log message: {
"timestamp": "2024-10-09T22:09:42.804Z",
"level": "Error",
"requestId": "2882bc48-17de-4d53-817e-b91aa1616a65",
"traceId": "Root=1-6706ff26-6370f67a168e1f2b3e1927ae;Parent=4fab4474991f77fa;Sampled=0;Lineage=1:ced1418f:0",
"message": null,
"errorType": "System.ArgumentException",
"errorMessage": "You said fail",
"stackTrace": [
"System.ArgumentException: You said fail",
"at Program.<>c.<<Main>$>b__0_0(String input, ILambdaContext context) in C:\\Users\\normj\\source\\repos\\StructuredLoggingWithException\\StructuredLoggingWithException\\Function.cs:line 10",
"at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass44_0`2.<GetHandlerWrapper>b__0(InvocationRequest invocation)",
"at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken)"
]
} |
Describe the bug
When I set lambda LoggingFormat to JSON, exception logs remains in TEXT format.
Regression Issue
Expected Behavior
I would expect all logs from lambda published to CloudWatch in JSON format, including fail' exception logs.
Current Behavior
Exception logs are not in JSON format.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Amazon.Lambda.Core 2.3.0
Targeted .NET Platform
.NET 8
Operating System and version
AmazonLinux
The text was updated successfully, but these errors were encountered: