You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
netstandard2.1 only, update to Serilog.Extensions.Hosting 4.0.0 to pull in CreateBootstrapLogger(), one sample (showing two-stage intialization), simplified README
@@ -81,7 +80,7 @@ That's it! With the level bumped up a little you will see log output resembling:
81
80
82
81
**Tip:** to see Serilog output in the Visual Studio output window when running under IIS, either select _ASP.NET Core Web Server_ from the _Show output from_ drop-down list, or replace `WriteTo.Console()` in the logger configuration with `WriteTo.Debug()`.
83
82
84
-
A more complete example, showing`appsettings.json` configuration, can be found in [the sample project here](https://github.com/serilog/serilog-aspnetcore/tree/dev/samples/EarlyInitializationSample).
83
+
A more complete example, including`appsettings.json` configuration, can be found in [the sample project here](https://github.com/serilog/serilog-aspnetcore/tree/dev/samples/Sample).
ThedownsideofinitializingSerilogfirstisthatservicesfromtheASP.NETCorehost, includingthe `appsettings.json` configurationanddependencyinjection, aren't available yet.
201
195
202
-
Thishastheadvantageofmakingaserviceproviderandthe `hostingContext`'s `Configuration` object available for [configuration of the logger](https://github.com/serilog/serilog-settings-configuration), but at the expense of losing `Exception`s raised earlier in program startup.
196
+
Toaddressthis, Serilogsupportstwo-stageinitialization. Aninitial"bootstrap"loggerisconfiguredimmediately when the program starts, and this is replaced by the fully-configured logger once the host has loaded.
Serilogsendseventstooutputscalled_sinks_, thatimplementSerilog's `ILogEventSink` interface, and are added to the logging pipeline using `WriteTo`. _Microsoft.Extensions.Logging_ has a similar concept called _providers_, and these implement `ILoggerProvider`. Providers are what the default logging configuration creates under the hood through methods like `AddConsole()`.
Bydefault, Serilogignoresproviders, sincethereareusuallyequivalentSerilogsinksavailable, andtheseworkmoreefficientlywithSerilog's pipeline. If provider support is needed, it can be optionally enabled.
It's important to note that the final logger **completely replaces** the bootstrap logger: if you want both to log to the console, for instance, you'llneedtospecify `WriteTo.Console()` inbothplaces, astheexampleshows.
Serilogsendseventstooutputscalled_sinks_, thatimplementSerilog's `ILogEventSink` interface, and are added to the logging pipeline using `WriteTo`. _Microsoft.Extensions.Logging_ has a similar concept called _providers_, and these implement `ILoggerProvider`. Providers are what the default logging configuration creates under the hood through methods like `AddConsole()`.
236
249
237
-
**Usinginlineinitialization:**
250
+
Bydefault, Serilogignoresproviders, sincethereareusuallyequivalentSerilogsinksavailable, andtheseworkmoreefficientlywithSerilog's pipeline. If provider support is needed, it can be optionally enabled.
238
251
239
-
If [inlineinitialization](#inline-initialization) isused, providerscanbeenabledbyadding`writeToProviders: true` tothe `UseSerilog()`methodcall:
0 commit comments