Open amirkaws opened 1 year ago
A couple of observations using the log method on the Logger instance
Throws an exception System.Reflection.TargetParameterCountException: Parameter count mismatch
, when using the LogInformation
with parameters
_logger.LogInformation("Testing with parameter Log Information Method {cityName}", cityName);
Have to explicitly pass the parameters as an object[]
for it to work like below.
_logger.LogInformation("Testing with parameter Log Information Method {cityName}", new[] { cityName });
Logged Parameters are not available in the output as destructured parameters. The above log statement outputs the below in CloudWatch
{
"cold_start": true,
"xray_trace_id": "1-654bd325-0acb33237c954016773e537b",
"function_name": "weathertest-LambdaEmptyFunction1FunctionGetWeather-zQceOL6olYxd",
"function_version": "$LATEST",
"function_memory_size": 256,
"function_arn": "arn:aws:lambda:ap-southeast-2:189107071895:function:weathertest-LambdaEmptyFunction1FunctionGetWeather-zQceOL6olYxd",
"function_request_id": "f32b5d3f-62eb-424c-9cbc-d5b0b48e3d0d",
"timestamp": "2023-11-08T18:27:50.6013375Z",
"level": "Information",
"service": "service_undefined",
"name": "LambdaEmptyFunction1.Function",
"message": "Testing with parameter Log Information Method Brisbane"
}
I expected the cityName
to be available in the log output.
Not sure if these are something that could be included as part of the documentation or am f I am missing something here? @amirkaws
Hi @rahulpnath thanks for raising the issue and thanks for the youtube video as well 😄 really cool.
So at the moment the way you add "addiitonal keys" is by calling the methods Logger.AppendKey
or Logger.AppendKeys
you can have a look in the docs.
The reason behind that approach was for the user experience to be the same across all Powertools runtimes. We now believe that we need a more .NET way to do logging, we are in the process of creating an RFC which will be similar to what you are alluding to, essentially resembling what ILogger does or what Serilog does.
Any input or feedback will be greatly appreciated, we don't have anything public yet, so if you have any ideas would love to hear them
What were you searching in the docs?
I am looking for the documentation to show me how to use typed logger, and interface based logger rather than Logger. static methods.
Is this related to an existing documentation section?
No response
How can we improve?
Got a suggestion in mind?
No response
Acknowledgment