-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Labels
area/loggingCore logging utilityCore logging utilityneed-rfcreleasedFix or implementation already in main and releasedFix or implementation already in main and releasedv2v2 releasev2 release
Milestone
Description
Expected Behaviour
Logger name should not be lost when object logged has a property called "name".
This is lost - "name": "AWS.Lambda.Powertools.Logging.Logger",
and replaced with "name": "Alan Adams",
.
If the object being logged has a TimeStamp
property, the Lambda timestamp will also be lost.
This problem relates to another bug.
Current Behaviour
The logger name is lost
{
"coldStart": true,
"xrayTraceId": "1-642af849-5a28de55210c2acf73933301",
"functionName": "ThreeSimpleWaysToLog",
"functionVersion": "$LATEST",
"functionMemorySize": 256,
"functionArn": "arn:aws:lambda:us-east-1:694977046108:function:ThreeSimpleWaysToLog",
"functionRequestId": "e882f2c8-24af-406a-ac5a-90c1031c3b65",
"name": "Alan Adams",
"age": 11,
"timestamp": "2023-04-03T16:01:14.3304021Z",
"level": "Information",
"service": "ThreeSimpleWaysToLog",
"message": "Alan Adams and is 11 years old"
}
Code snippet
using Amazon.Lambda.Core;
using AWS.Lambda.Powertools.Logging;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace ThreeSimpleWaysToLog;
public class Function
{
[Logging(LogEvent = true, LoggerOutputCase = LoggerOutputCase.CamelCase)]
public void FunctionHandler(string input, ILambdaContext context)
{
Person person = new Person { Name ="Alan Adams", Age = 11 };
Logger.LogInformation<Person>(person, "{Name} and is {Age} years old", new object[]{person.Name, person.Age});
}
}
public class Person
{
public string Name {get ; set;}
public int Age { get; set; }
}
Possible Solution
The Person
should be have be represented in the JSON under a Person
property.
"person": {
"name": "Alan Adams",
"age": 11
}
### Steps to Reproduce
Deploy the code above and invoke
### AWS Lambda Powertools for .NET version
latest
### AWS Lambda function runtime
dotnet6
### Debugging logs
_No response_
Metadata
Metadata
Labels
area/loggingCore logging utilityCore logging utilityneed-rfcreleasedFix or implementation already in main and releasedFix or implementation already in main and releasedv2v2 releasev2 release
Type
Projects
Status
✅ Done