-
Notifications
You must be signed in to change notification settings - Fork 478
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
Lambda multiline logging messages - different behaviour between Zip & Image (docker) package type #1662
Comments
Also an issue with the dotnet:7 runtime image |
This is a limitations with container based Lambda functions. For zip based Lambda functions the Lambda environment is given a special endpoint to send the logs to and we can send the log messages as your code sends them. But with container based images that special endpoint doesn't exist. Logs in containers is basically scrapping stdout and when doing that their is no context when a log message ends so newlines is used in the absence of anything better coming from stdout. If you are curious from the .NET side here is the code in the .NET Lambda runtime client that chooses between the 2 different systems. https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.RuntimeSupport/Helpers/ConsoleLoggerWriter.cs#L156 |
I believe Amazon.Lambda.Logging.AspNetCore has the same issue?
So we have to write our own custom ILoggerProvider if we want to use containers?? Seems a bit ridiculous? |
Any update on this issue? |
Lambda has no plans to change how containers are run to provide access to the separate telemetry API. Once we get structured logging support in place for .NET that will provide you a work around where the whole structured logging will be compressed into a single line with newlines being escaped. I'm going to close this issue but if you want to track the structured logging support follow this PR. |
Comments on closed issues are hard for our team to see. |
Describe the bug
Simple Lambda function with
Console.WriteLine
statements will behave differently for Zip & image (docker) packagesConsole logging of a multi-line statement eg:
Console.WriteLine("Multi line example" + Environment.NewLine + "Multi line example");
will appear as one CloudWatch entry when deployed using a zip file but will appear as two CloudWatch entries in a docker runtime
This is also an issue using logging providers such as Microsoft.Extensions.Logging.Console & Amazon.Lambda.Logging.AspNetCore. (probably because they all use Amazon.Lambda.Core.LambdaLogger?)
Expected Behavior
One logging message should be written to one CloudWatch entry.
Behaviour should be consistent.
Current Behavior
Behaviour is not consistent.
There is one CloudWatch entry when deployed using a zip file but two CloudWatch entries in a docker runtime.
Reproduction Steps
Simple lambda function:
Zip deployment:
Docker deployment:
Possible Solution
Issue probably in Amazon.Lambda.Core.LambdaLogger ?
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Targeted .NET Platform
net6.0 / net7.0
Operating System and version
The text was updated successfully, but these errors were encountered: