ILogger added via `AddLambdaLogger` logs everything as [Information]

1.5k Views Asked by At

I recently added logging to a AWS Lambda function and noticed something weird when I checked the logs.

Everything being logged via the logger was showing as [Information] even if the call was specifically to log as a Warning or Error.

Here is where I set up the logger:

serviceCollection.AddLogging(logging =>
{
    logging.AddLambdaLogger();
    logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Information);
});

and it gets injected as an instance of ILogger as a constructor parameter like this:

ILogger<MyClass> logger

So when I call something like

_logger.LogWarning($"Oh no");

I would expect it to log that as [Warning] but in the logs it shows as [Information]

0

There are 0 best solutions below