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:
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.
Log Levels
Section titled “Log Levels”The OidcClient logs at the following levels:
TraceDebugInformationError
You can set the log level in your appsettings.json by modifying the following snippet.
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information", "Duende.IdentityModel.OidcClient": "Error" } }}