Logging Fundamentals
All Duende Software products (IdentityServer, Backend for Frontend (BFF), Access Token Management, etc.) use the standard logging facilities provided by ASP.NET Core (Microsoft.Extensions.Logging).
This means they integrate seamlessly with whatever logging provider you choose for your application.
This guide provides general instructions for setting up logging that apply to all our products.
Log Levels
Section titled “Log Levels”We follow the standard Microsoft guidelines for log levels. The spectrum below shows where each level sits on the operational urgency scale, with a quick action guide for each.
| Level | Urgency | Action |
|---|---|---|
| Trace | Dev only | Support-requested diagnostics only. Contains sensitive data. |
| Debug | Dev/Staging | Enable in dev/staging. Disable before production. May contain sensitive data. |
| Information | Monitor | Normal operations. Good default for production. |
| Warning | Investigate | Review when convenient. May indicate misconfiguration. |
| Error | Act soon | Investigate promptly. Something failed. |
| Critical | Act now! | Act immediately. System may be down. |
Scroll down for detailed guidance on what each level means, who it affects, and what you should do when you see it.
Meaning: Extremely detailed diagnostic information intended for developers debugging complex, hard-to-reproduce issues.
Customer impact: None directly. Trace is never enabled in production under normal circumstances.
Action:
- Do not enable in production unless Duende Support explicitly requests it.
- If you must enable it, use a scoped namespace (e.g.,
Duende.IdentityServer) to limit output. - Secure and rotate your logs immediately after capturing diagnostics.
- Disable as soon as the issue is diagnosed.
Example:
[Trace] Duende.IdentityServer.Validation.TokenValidator Validating JWT token: eyJhbGciOiJSUzI1NiIs...Meaning: Internal flow details: why decisions were made, which code paths were taken (e.g., policy evaluation, token validation steps).
Customer impact: None directly. Debug is for developer understanding, not user-facing operations.
Action:
- Enable during local development or staging to understand application behavior.
- Use
appsettings.Development.jsonto isolate Debug logging from production config. - Disable before deploying to production, or set an expiry reminder.
Example:
[Debug] Duende.IdentityServer.ResponseHandling.AuthorizeResponseGenerator Creating authorization code response for client 'spa-app'Information
Section titled “Information”Meaning: High-level events that track the normal flow of the application: requests starting, tokens issued, sessions created.
Customer impact: Minimal. These are expected events. Absence of expected Information logs may indicate a problem.
Action:
- No immediate action required. This is normal operational noise.
- Use Information logs for auditing user activity and correlating requests by ID.
- This is often the recommended default level for production.
Example:
[Information] Duende.IdentityServer.Hosting.IdentityServerMiddleware Invoking IdentityServer endpoint: /connect/token (TokenEndpoint)Warning
Section titled “Warning”Meaning: Unexpected events that did not stop the application, but may indicate misconfiguration, an edge case, or degraded behavior.
Customer impact: Possible. Some users may be experiencing issues. Investigate to confirm impact.
Action:
- Review the warning message and context (correlation ID, client ID, user).
- Check if the warning is recurring or isolated. Recurring warnings deserve prompt attention.
- Common causes: invalid client configuration, deprecated settings, transient infrastructure issues.
- If in doubt, open a support ticket with Duende.
Example:
[Warning] Duende.IdentityServer.Validation.ClientSecretValidator Client secret validation failed for client 'legacy-app'Meaning: An operation failed and could not recover. An exception was thrown and not handled gracefully.
Customer impact: Likely. A user request probably failed. Investigate promptly.
Action:
- Check the full stack trace in your log sink.
- Correlate with the request ID or user subject ID to identify scope.
- Determine if the error is recurring or isolated.
- If recurring: escalate to your team and open a Duende Support ticket if needed.
- Check whether downstream dependencies (database, external IdP) are healthy.
Example:
[Error] Duende.IdentityServer.Validation.TokenRequestValidator Failed validation of token request: invalid_grantCritical
Section titled “Critical”Meaning: A catastrophic failure that requires immediate attention. The system may be partially or fully unable to function.
Customer impact: High. Users are likely unable to authenticate or obtain tokens.
Action:
- Act immediately. Page your on-call team.
- Check startup logs. Critical events often occur at startup (missing signing key, missing store implementation).
- Verify database connectivity and key material availability.
- Review deployment changes made immediately before the issue started.
- Contact Duende Support with your logs if the cause is unclear.
Example:
[Critical] Duende.IdentityServer.Startup No signing key material found. IdentityServer cannot issue tokens.Environment Configuration
Section titled “Environment Configuration”Use this table as a quick reference for which log levels to enable in each environment:
| Level | Development | Staging | Production |
|---|---|---|---|
| Trace | ⚠️ Temporarily, for active investigations | ❌ Disable | ❌ Disable (Enable under extreme circumstances only) |
| Debug | ✅ Recommended | ⚠️ Temporarily, for active investigations | ❌ Disable |
| Information | ✅ | ✅ Recommended | ⚠️ Temporarily, for active investigations |
| Warning | ✅ | ✅ | ✅ Recommended |
| Error | ✅ | ✅ | ✅ |
| Critical | ✅ | ✅ | ✅ (with alerts) |
Setup for Microsoft.Extensions.Logging
Section titled “Setup for Microsoft.Extensions.Logging”This is the default logging provider for ASP.NET Core. If you haven’t configured a third-party logger, this is what you are using.
You can configure log levels in your appsettings.json file. To get detailed logs from Duende products, you often want to set the Duende namespace (or specific sub-namespaces) to Debug.
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information", // Enable Debug logs for all Duende products "Duende": "Debug" } }}Setup for Serilog
Section titled “Setup for Serilog”Serilog is a popular structured logging library for .NET. We highly recommend it for its flexibility and rich sink ecosystem (Console, File, Seq, Elasticsearch, etc.).
1. Installation
Section titled “1. Installation”Install the necessary packages:
dotnet add package Serilog.AspNetCore2. Configuration In Program.cs
Section titled “2. Configuration In Program.cs”Configure Serilog early in your application startup to capture all logs, including startup errors.
using Serilog;
var builder = WebApplication.CreateBuilder(args);
// Configure Serilogbuilder.Host.UseSerilog((ctx, lc) => lc .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}") .Enrich.FromLogContext() .ReadFrom.Configuration(ctx.Configuration));
var app = builder.Build();
app.UseSerilogRequestLogging(); // Optional: cleaner HTTP request logging
// ... rest of your pipeline3. Configuration In appsettings.json
Section titled “3. Configuration In appsettings.json”You can then control log levels via appsettings.json. This approach allows you to change log levels without recompiling your code.
{ "Serilog": { "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information", "System": "Warning", // Enable detailed logging for Duende products "Duende": "Debug" } } }}Troubleshooting Specific Products and Components
Section titled “Troubleshooting Specific Products and Components”If you are debugging a specific component, you can target its namespace to reduce noise.
| Product | Namespace |
|---|---|
| IdentityServer | Duende.IdentityServer |
| BFF | Duende.Bff |
| User Management | Duende.UserManagement |
| Access Token Management | Duende.AccessTokenManagement |
Example appsettings.json for debugging only BFF interactions:
"Duende.Bff": "Debug","Duende.IdentityServer": "Information"Product-Specific Guides
Section titled “Product-Specific Guides”Each Duende product has its own logging page with product-specific configuration namespaces, key events to watch for, and advanced topics.