Search code examples
aws-sdkasp.net-core-logging

How to filter 'AWSSDK.Extensions.NETCore.Setup' logs in .Net Core appsettings.json


I am trying to add a logging filter in my .Net core application for 'AWSSDK.Extensions.NETCore.Setup'. However, when I add the full namespace it is not filtering the logs but if I put only AWSSDK then filtering is working fine. Could someone please guide me what am I missing? This is a snippet from my appsettings.json file.

"Logging": {
        "LogLevel": {
            "Default": "Information",
            "AWSSDK.Extensions.NETCore.Setup": "Warning"
        }
}

The logs I am trying to filter are these: [Information] Found AWS credentials for the profile test


Solution

  • The confusing part here is that Microsoft often (if not always) uses the fully qualified type name when creating a logger, which is why it seems like the namespace could be used in appsettings.json, but that is not correct.

    You need to use the category name, which is provided when creating the logger with LoggerFactory.CreateLogger. In this case, Amazon has elected to simply use AWSSDK rather than the full type name.

    ClientFactory.cs enter image description here

    Unfortunately, that likely means that you will not be able to configure anything more specific in your appsettings.json, but at least you'll be able to suppress some of the noisy informational logs.