AWS.Lambda.Powertools.Logging
                               
                            
                                1.6.2-alpha
                            
                        
                            
                                
                                
                                    Prefix Reserved
                                
                            
                    
        
        
                                This is a prerelease version of AWS.Lambda.Powertools.Logging.
                            
    
    
        
        
                                There is a newer version of this package available.
                                
See the version list below for details.
                    See the version list below for details.
dotnet add package AWS.Lambda.Powertools.Logging --version 1.6.2-alpha
NuGet\Install-Package AWS.Lambda.Powertools.Logging -Version 1.6.2-alpha
        
        
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
                    
    
    <PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.2-alpha" />
        
        
For projects that support PackageReference, copy this XML node into the project file to reference the package.
                    
    
    <PackageVersion Include="AWS.Lambda.Powertools.Logging" Version="1.6.2-alpha" />
<PackageReference Include="AWS.Lambda.Powertools.Logging" />
        
        
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
                    
    
    paket add AWS.Lambda.Powertools.Logging --version 1.6.2-alpha
        
        
 The NuGet Team does not provide support for this client. Please contact its maintainers for support.
                    
    
    #r "nuget: AWS.Lambda.Powertools.Logging, 1.6.2-alpha"
        
        
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
                    
    
    #:package AWS.Lambda.Powertools.Logging@1.6.2-alpha
        
        
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
                    
    
    #addin nuget:?package=AWS.Lambda.Powertools.Logging&version=1.6.2-alpha&prerelease
#tool nuget:?package=AWS.Lambda.Powertools.Logging&version=1.6.2-alpha&prerelease
        
        
 The NuGet Team does not provide support for this client. Please contact its maintainers for support.
                    
    
    AWS.Lambda.Powertools.Logging
The logging utility provides a AWS Lambda optimized logger with output structured as JSON.
Key features
- Capture key fields from Lambda context, cold start and structures logging output as JSON
- Log Lambda event when instructed (disabled by default)
- Log sampling enables DEBUG log level for a percentage of requests (disabled by default)
- Append additional keys to structured log at any point in time
Read the docs
For a full list of features go to docs.powertools.aws.dev/lambda/dotnet/core/logging/
GitHub: https://github.com/aws-powertools/powertools-lambda-dotnet/
Sample Function
public class Function
{
    [Logging(LogEvent = true)]
    public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigwProxyEvent,
        ILambdaContext context)
    {
        var requestContextRequestId = apigwProxyEvent.RequestContext.RequestId;
        
        var lookupInfo = new Dictionary<string, object>()
        {
            {"LookupInfo", new Dictionary<string, object>{{ "LookupId", requestContextRequestId }}}
        };
        // Appended keys are added to all subsequent log entries in the current execution.
        // Call this method as early as possible in the Lambda handler.
        // Typically this is value would be passed into the function via the event.
        // Set the ClearState = true to force the removal of keys across invocations,
        Logger.AppendKeys(lookupInfo);
        Logger.LogInformation("Getting ip address from external service");
        var location = await GetCallingIp();
        var lookupRecord = new LookupRecord(lookupId: requestContextRequestId,
            greeting: "Hello Powertools for AWS Lambda (.NET)", ipAddress: location);
        try
        {
            await SaveRecordInDynamo(lookupRecord);
            
            return new APIGatewayProxyResponse
            {
                Body = JsonSerializer.Serialize(lookupRecord),
                StatusCode = 200,
                Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
            };
        }
        catch (Exception e)
        {
            Logger.LogError(e.Message);
            return new APIGatewayProxyResponse
            {
                Body = e.Message,
                StatusCode = 500,
                Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
            };
        }
    }
}
Sample output
{
    "cold_start": false,
    "xray_trace_id": "1-623d34cb-00c3698b02f11dc713442693",
    "lookup": {
        "lookup_id": "7d2ce9bb-c7d1-4304-9912-6078d276604f"
    },
    "function_name": "PowertoolsLoggingSample-HelloWorldFunction-hm1r10VT3lCy",
    "function_version": "$LATEST",
    "function_memory_size": 256,
    "function_arn": "arn:aws:lambda:ap-southeast-2:111111111111:function:PowertoolsLoggingSample-HelloWorldFunction-hm1r10VT3lCy",
    "function_request_id": "f5c3bae7-0e18-495a-9959-ef101c7afbc0",
    "timestamp": "2022-03-25T03:19:39.9322301Z",
    "level": "Information",
    "service": "powertools-dotnet-logging-sample",
    "name": "AWS.Lambda.Powertools.Logging.Logger",
    "message": "Getting ip address from external service"
}
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
        
        Compatible target framework(s)
    
    
        
        Included target framework(s) (in package)
    
    Learn more about Target Frameworks and .NET Standard.
- 
                                                    net6.0- Amazon.Lambda.Core (>= 2.2.0)
- Amazon.Lambda.Serialization.SystemTextJson (>= 2.4.3)
- AspectInjector (>= 2.8.1)
- Microsoft.Extensions.Logging (>= 8.0.0)
 
- 
                                                    net8.0- Amazon.Lambda.Core (>= 2.2.0)
- Amazon.Lambda.Serialization.SystemTextJson (>= 2.4.3)
- AspectInjector (>= 2.8.1)
- Microsoft.Extensions.Logging (>= 8.0.0)
 
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AWS.Lambda.Powertools.Logging:
| Package | Downloads | 
|---|---|
| Lambifast Package Description | 
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on AWS.Lambda.Powertools.Logging:
| Repository | Stars | 
|---|---|
| aws/aws-lambda-dotnet 
                                                            Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
                                                         | |
| aws-samples/serverless-test-samples 
                                                            This repository is designed to provide guidance for implementing comprehensive test suites for serverless applications.
                                                         | |
| aws-samples/serverless-dotnet-demo | 
| Version | Downloads | Last Updated | 
|---|---|---|
| 3.0.1 | 1,495 | 10/21/2025 | 
| 3.0.1-alpha | 160 | 10/15/2025 | 
| 3.0.0 | 1,857 | 10/8/2025 | 
| 2.0.2 | 20,631 | 8/26/2025 | 
| 2.0.1 | 15,357 | 7/29/2025 | 
| 2.0.0 | 147,097 | 5/6/2025 | 
| 2.0.0-preview.1 | 4,019 | 4/8/2025 | 
| 1.7.0 | 33,540 | 4/8/2025 | 
| 1.6.5 | 61,376 | 3/7/2025 | 
| 1.6.4 | 63,037 | 1/28/2025 | 
| 1.6.3 | 15,926 | 1/14/2025 | 
| 1.6.2 | 295,326 | 10/22/2024 | 
| 1.6.2-alpha2 | 2,310 | 10/9/2024 | 
| 1.6.2-alpha | 138 | 10/9/2024 | 
| 1.6.1 | 68,497 | 10/2/2024 | 
| 1.6.0 | 22,312 | 9/24/2024 | 
| 1.6.0-alpha | 30,186 | 2/21/2024 | 
| 1.5.1 | 286,830 | 3/10/2024 | 
| 1.4.4 | 147,665 | 11/16/2023 | 
| 1.3.3 | 17,027 | 10/30/2023 | 
| 1.3.2 | 36,138 | 9/19/2023 | 
| 1.2.0 | 16,174 | 8/22/2023 | 
| 1.1.1 | 33,102 | 6/21/2023 | 
| 1.1.0 | 32,806 | 5/5/2023 | 
| 1.0.1 | 37,412 | 4/6/2023 | 
| 1.0.0 | 14,146 | 2/24/2023 | 
| 0.0.2-preview | 2,045 | 1/18/2023 | 
| 0.0.1-preview.1 | 5,905 | 8/1/2022 |