-
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
ILambdaLogger.LogLine(...) behaviour changed between .Net 5 and .Net 6 #973
Comments
Reproducible. While we cannot use Visual Studio 2019 for .NET 6 targets, AWS extensions for .NET CLI could be used to deploy the updated project with target as |
The change in behaviour appears to be due to changing the IConsoleLoggerWriter implementation from SimpleLoggerWriter to LogLevelLoggerWriter. aws-lambda-dotnet/Libraries/src/Amazon.Lambda.RuntimeSupport/Helpers/ConsoleLoggerWriter.cs Line 203 in 70d6a97
|
The change was done on purpose because getting request id in the logging statement like other Lambda runtimes was a highly requested feature. I understand your use case of wanting to pass in a JSON string to |
My current workaround when reading back log messages is to split on \t then deserialise the last field. Having an environment variable to revert to the previous logging behaviour would work for me. |
Are there any plans to integrate the requestId feature into the I'm currently using a modified |
@El-Gor-do Amazon.Lambda.RuntimeSupport 1.5.0 adds support for environment variable |
I have tested Amazon.Lamda.RuntimeSupport 1.5.0 with AWS_LAMBDA_HANDLER_LOG_FORMAT=Unformatted. The CloudWatch Logs message contains an additional trailing newline character whereas the previous .Net 5 behaviour wrote the message exactly as passed without appending a newline character. For my use case this doesn't matter but it might be an issue for other users. |
Just found this issue. Not urgent, but would it be possible to have this exposed programmatically? We have an internal framework which builds on top of this library we use in a number of different Lambda solutions, where this library is referenced transitively. We also use JSON-formatted logging. To apply this fix, as well as updating our framework library, this also needs us to apply the environment variable in each lambda project. It would be easier to roll out the fix centrally if our base library could just set the level to Unformatted itself. |
@martincostello Please raise a new feature request mentioning all the details about your use case. |
@ashishdhingra I've raised #1000. |
Closing this issue since the changes have been implemented and for programmatic behavior a new feature request is created. |
|
Description
In .Net 5, ILambdaLogger.LogLine("hello world") would be logged to CloudWatch Logs exactly as
After changing my Lambda project's TargetFramework from net5.0 to net6.0, the same call to ILambdaLogger.LogLine is logged to CloudWatch Logs as "{timestamp}\t{requestId}\t{level}\t{message}"
In my real Lambda project, my message is a json string which I subsequently deserialise. With the new behaviour in .Net 6, the message is no longer valid json because of the extra tab-delimited fields in each message.
Reproduction Steps
In a custom runtime Lambda, set the function handler to this
Deploy this Lambda using TargetFramework net5.0 then invoke the function and check the CloudWatch Logs output. The log event's message will be "hello world". Deploy the Lambda again using TargetFramework net6.0 then invoke the function again and check the CloudWatch Logs output again. The log event's message will have tab-delimited fields followed by "hello world".
Environment
Resolution
I would like the .Net 6 behaviour to return to the previous .Net 5 behaviour where the log event's message is exactly as I passed to ILambdaLogger.LogLine(...)
This is a 🐛 bug-report
The text was updated successfully, but these errors were encountered: