OidcClient does not use the ASP.NET Core dependency injection container directly — instead, you configure it by setting the LoggerFactory property on OidcClientOptions. This gives you full control over logging in native app, mobile, and console scenarios.
Program.cs
usingDuende.IdentityModel;
usingDuende.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
};
returnnew OidcClient(options);
});
var app =builder.Build();
var client =app.Services.GetService<OidcClient>();
You can use any logging framework that integrates with ILoggerFactory, such as Serilog.
OidcClient emits logs at Trace, Debug, Information, and Error levels. To control log output, set the Duende.IdentityModel.OidcClient namespace in your appsettings.json:
OidcClient emits structured log messages across several functional areas. Each message includes contextual parameters for effective filtering and troubleshooting.
The IdentityProvider contains a pushed authorization request endpoint. Automatically pushing authorization parameters. Use DisablePushedAuthorization to opt out.