How to disable the log of certain c# routes using iLogger?

Asked

Viewed 14 times

-1

I currently use Microsoft’s own Logger to log the application, as follows:

if (environment != null && !environment.IsLocal() && !environment.IsDocker())
            {
                return loggingBuilder
                        .ClearProviders()
                        .AddAWSProvider();
            }
            else
            {
                return loggingBuilder
                        .ClearProviders()
                        .AddConsoleLogger()
                        .AddConsoleLogger(LogLevel.Warning, ConsoleColor.Yellow)
                        .AddConsoleLogger(LogLevel.Error, ConsoleColor.Red);
            }

But as can be seen in the code snippet, business environment logs are sent to AWS Cloudwatch, where we have all the infrastructure. In AWS is carried out regularly the call of Healthcheck, which generates logs in the same way and so our logs are getting extremely polluted due to the amount of calls to Healthcheck.

How do I not log in to Healthcheck calls?

I’ve tried through middleware, but I can’t make a CleanProviders() there.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.