yithril
yithril

Reputation: 67

Identity Server Providing too many logs in Serilog

I just set up Serilog for .Net Core with a Seq sink. It is writing to Seq perfectly. My problem is that the Identity Server is writing a lot of logs I find unnecessary, and I thought I had set the log level to filter those out. Can I filter these out by filtering out the source context?

Here is an example of the logs with the app name redacted: enter image description here

I just need User Logged in and not any of the stuff above it. My appsettings.json looks like this:

 "Serilog": {
    "Using": [ "Serilog.Sinks.Seq", "Serilog" ],
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Error",
        "Microsoft.AspNetCore": "Error"
      }
    },
    "WriteTo": [
      {
        "Name": "Seq",
        "Args": { "serverUrl": "http://seqserver"  }
      }
    ],
    "Enrich": [ "FromLogContext", "WithMachineName" ],
    "Properties": {
      "Application": "App"
    }
  }

My Program.cs looks like this:

 public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .UseSerilog((context, config) =>
                {
                    config.ReadFrom.Configuration(context.Configuration)
                        .Enrich.FromLogContext()
                        .Enrich.WithProperty("Environment", context.HostingEnvironment);
                })
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });

Upvotes: 0

Views: 942

Answers (1)

Kahbazi
Kahbazi

Reputation: 15015

You can override the default level for IdentityServer

 "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Error",
        "Microsoft.AspNetCore": "Error",
        "IdentityServer": "Information"
      }
    },

Upvotes: 6

Related Questions