Open bjhogan opened 1 year ago
@bjhogan thanks for reporting. Having a look
Related to #116
Hi @bjhogan, thanks for opening the issue. The extraKeys parameter in Logger.LogInformation(extraKeys, "message"), expect dictionary or a list of key/value pairs. So the object also be treated as a bag of key/value pair and will be logged in the root level. You can pass "person" object as value in combination with the key name to achieve the desired outcome.
var extraKeys = new { Person = person };
Logger.LogInformation(extraKeys, $"{person.Name} and is {person.Age} years old");
On a separate notes, we have already another issue https://github.com/awslabs/aws-lambda-powertools-dotnet/issues/166 to improve the documentation.
Expected Behaviour
For an object
Person
, that has anAddress
I expect to see it logged like this -When logging using
Logger.LogInformation<Person>(person, "{Name} and is {Age} years old", new object[]{person.Name, person.Age});
I expect the output to look like -Current Behaviour
Instead the output is -
Person is lost.
Code snippet
Possible Solution
I would expect the log out to look the same as it does when using like this -
The output from this is -
The Person is clearly shown.
Steps to Reproduce
Deploy the code provided and invoke.
AWS Lambda Powertools for .NET version
latest
AWS Lambda function runtime
dotnet6
Debugging logs
No response