powertools-lambda-dotnet
powertools-lambda-dotnet copied to clipboard
Docs: Improve Logger documentations typed logger
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.
public class Function
{
private static ILogger _logger;
public Function()
{
_logger = Logger.Create<Function>();
}
[Logging(LogEvent = true)]
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigwProxyEvent,
ILambdaContext context)
{
_logger.LogInformation(new { LogLocation = "FunctionHandler" }, "Test Message");
...
}
}
{
"cold_start": true,
"xray_trace_id": "1-61b7add4-66532bb81441e1b060389429",
"function_name": "test",
"function_version": "$LATEST",
"function_memory_size": 128,
"function_arn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
"timestamp": "2021-12-13T20:32:22.5774262Z",
"level": "Information",
"service": "lambda-example",
"name": "HelloWorld.Function",
"message": "Collecting payment",
"sampling_rate": 0.7,
"correlation_id": "correlation_id_value"
}
Is this related to an existing documentation section?
No response
How can we improve?
Add a section in documentation related to typed logger, and another one for dependency injection
Got a suggestion in mind?
No response
Acknowledgment
- [X] I understand the final update might be different from my proposed suggestion, or refused.