Skip to content

Commit 3ac9a9a

Browse files
authored
Merge pull request #971 from DuendeSoftware/mb/serilog
Update Serilog to use AddSerilog instead of UseSerilog
2 parents 661ad0c + 7af9e86 commit 3ac9a9a

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/content/docs/identityserver/diagnostics/data.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ When using [Serilog](https://serilog.net/), you can configure a separate file lo
148148
{/* prettier-ignore */}
149149
<Tabs>
150150
<TabItem label="In code">
151-
In the `UseSerilog()` extension method's configuration builder, you can add a file logger that
151+
In the `AddSerilog()` extension method's configuration builder, you can add a file logger that
152152
filters log messages and only emits those from the `Duende.IdentityServer.Diagnostics.Summary` category.
153153

154154
The console logger (or another default logger you are using) can be configured to exclude this category.
@@ -157,10 +157,10 @@ When using [Serilog](https://serilog.net/), you can configure a separate file lo
157157
lang="csharp"
158158
title="Program.cs"
159159
code={`// ...
160-
builder.Host.UseSerilog((context, services, configuration) =>
160+
builder.Services.AddSerilog((services, configuration) =>
161161
{
162162
configuration
163-
.ReadFrom.Configuration(context.Configuration)
163+
.ReadFrom.Configuration(builder.Configuration)
164164
.ReadFrom.Services(services)
165165
.Enrich.FromLogContext()
166166
.MinimumLevel.Debug()

src/content/docs/identityserver/diagnostics/logging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ To do so, you first need to tell Serilog to read its configuration from the `ICo
173173
174174
var builder = WebApplication.CreateBuilder(args);
175175

176-
builder.Host.UseSerilog((ctx, lc) => lc
176+
builder.Services.AddSerilog(lc => lc
177177
.WriteTo.Console(
178178
outputTemplate:
179179
"[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}",
180180
formatProvider: CultureInfo.InvariantCulture)
181181
.Enrich.FromLogContext()
182-
.ReadFrom.Configuration(ctx.Configuration));
182+
.ReadFrom.Configuration(builder.Configuration));
183183
```
184184

185185
Then, in your `appsettings.json` file, you can set the default minimum log level and log level overrides like so:

0 commit comments

Comments
 (0)