diff --git a/README.md b/README.md index 2537852..c9b5bb6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Log.CloseAndFlush(); The sink can take advantage of Seq's [API keys](http://docs.getseq.net/docs/api-keys) to authenticate clients and dynamically attach properties to events at the server-side. To use an API key, specify it in the `apiKey` parameter of `WriteTo.Seq()`. -### Configuring with XML +### XML `` configuration To adjust the Seq server URL at deployment time, it's often convenient to configure it using XML ``, in the `App.config` or `Web.config` file. @@ -64,6 +64,41 @@ The settings typically included are: Serilog's XML configuration has several other capabilities that are described on the [Serilog wiki](https://github.com/serilog/serilog/wiki/AppSettings). +### JSON `appsettings.json` configuration + +To use the Seq sink with _Microsoft.Extensions.Configuration_, for example with ASP.NET Core or .NET Core, use the [Serilog.Settings.Configuration](https://github.com/serilog/serilog-settings-configuration) package. First install that package if you have not already done so: + +```powershell +Install-Package Serilog.Settings.Configuration +``` + +Instead of configuring the Seq sink directly in code, call `ReadFrom.Configuration()`: + +```csharp +var configuration = new ConfigurationBuilder() + .AddJsonFile("appsettings.json") + .Build(); + +var logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); +``` + +In your `appsettings.json` file, under the `Serilog` node, : + +```json +{ + "Serilog": { + "WriteTo": [ + { "Name": "Seq", "Args": { "serverUrl": "http://localhost:5341" } } + ] + } +} +``` + +See the XML `` example above for a discussion of available `Args` options. + + ### Dynamic log level control The Seq sink can dynamically adjust the logging level up or down based on the level associated with an API key in Seq. To use this feature, create a `LoggingLevelSwitch` to control the `MinimumLevel`, and pass this in the `controlLevelSwitch` parameter of `WriteTo.Seq()`: