Skip to content

Commit

Permalink
Merge pull request #167 from phlashdev/clarify-readme
Browse files Browse the repository at this point in the history
Update Instructions for .NET Core 3 templates
  • Loading branch information
nblumhardt authored Jan 24, 2020
2 parents ffed9d2 + 71b0f0b commit 21c14f6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Program
try
{
Log.Information("Starting web host");
CreateWebHostBuilder(args).Build().Run();
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
Expand All @@ -46,21 +46,22 @@ public class Program
}
```

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

```csharp
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseSerilog(); // <-- Add this line;
}
```

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

* Remove calls to `AddLogging()`
* 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)
* Remove `ILoggerFactory` parameters and any `Add*()` calls on the logger factory in _Startup.cs_
* Remove `UseApplicationInsights()` (this can be replaced with the [Serilog AI sink](https://github.com/serilog/serilog-sinks-applicationinsights), if required)

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

0 comments on commit 21c14f6

Please # to comment.