-
Notifications
You must be signed in to change notification settings - Fork 24
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
Format of JSON not as expected #230
Comments
@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 #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
The text was updated successfully, but these errors were encountered: