Skip to content

Commit 21c14f6

Browse files
authored
Merge pull request #167 from phlashdev/clarify-readme
Update Instructions for .NET Core 3 templates
2 parents ffed9d2 + 71b0f0b commit 21c14f6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Program
3131
try
3232
{
3333
Log.Information("Starting web host");
34-
CreateWebHostBuilder(args).Build().Run();
34+
CreateHostBuilder(args).Build().Run();
3535
return 0;
3636
}
3737
catch (Exception ex)
@@ -46,21 +46,22 @@ public class Program
4646
}
4747
```
4848

49-
**Then**, add `UseSerilog()` to the web host builder in `BuildWebHost()`.
49+
**Then**, add `UseSerilog()` to the Generic Host in `CreateHostBuilder()`.
5050

5151
```csharp
52-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
53-
WebHost.CreateDefaultBuilder(args)
54-
.UseStartup<Startup>()
52+
public static IHostBuilder CreateHostBuilder(string[] args) =>
53+
Host.CreateDefaultBuilder(args)
54+
.ConfigureWebHostDefaults(webBuilder =>
55+
{
56+
webBuilder.UseStartup<Startup>();
57+
})
5558
.UseSerilog(); // <-- Add this line;
5659
}
5760
```
5861

5962
**Finally**, clean up by removing the remaining configuration for the default logger:
6063

61-
* Remove calls to `AddLogging()`
6264
* Remove the `"Logging"` section from _appsettings.json_ files (this can be replaced with [Serilog configuration](https://github.com/serilog/serilog-settings-configuration) as shown in [the _EarlyInitializationSample_ project](https://github.com/serilog/serilog-aspnetcore/blob/dev/samples/EarlyInitializationSample/Program.cs), if required)
63-
* Remove `ILoggerFactory` parameters and any `Add*()` calls on the logger factory in _Startup.cs_
6465
* Remove `UseApplicationInsights()` (this can be replaced with the [Serilog AI sink](https://github.com/serilog/serilog-sinks-applicationinsights), if required)
6566

6667
That's it! With the level bumped up a little you will see log output resembling:

0 commit comments

Comments
 (0)