Skip to content
Livestream: Why now's a good time to upgrade to Duende IdentityServer and .NET 10. Register Now!

OIDC Client Logging

OidcClient logs errors, warnings, and diagnostic information using Microsoft.Extensions.Logging.ILogger, the standard .NET logging library.

You can use any logging provider to store your logs however you like, by setting the LoggerFactory property on OidcClientOptions:

Program.cs
using Duende.IdentityModel;
using Duende.IdentityModel.OidcClient;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddSingleton(svc =>
{
var loggerFactory = svc.GetRequiredService<ILoggerFactory>();
var options = new OidcClientOptions
{
Authority = "https://demo.duendesoftware.com",
ClientId = "interactive.public",
Scope = "openid profile email offline_access",
RedirectUri = "app://localhost/",
PostLogoutRedirectUri = "app://localhost/",
LoggerFactory = loggerFactory
};
return new OidcClient(options);
});
var app = builder.Build();
var client = app.Services.GetService<OidcClient>();

Using this approach, you can use other logging frameworks, like Serilog for example.

For general information on how to configure logging in .NET applications, see our Logging Fundamentals guide.

The OidcClient logs at the following levels:

  • Trace
  • Debug
  • Information
  • Error

You can set the log level in your appsettings.json by modifying the following snippet.

appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Duende.IdentityModel.OidcClient": "Error"
}
}
}