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
Copy file name to clipboardExpand all lines: README.md
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,27 +10,20 @@ This package makes it a one-liner to configure ASP.NET Core logging with Seq.
10
10
11
11
### Getting started
12
12
13
-
The instructions that follow are for **.NET Core 2.0+**.
13
+
The instructions that follow are for **.NET 6.0+** web applications.
14
14
15
15
Add [the NuGet package](https://nuget.org/packages/seq.extensions.logging) to your project either by editing the CSPROJ file, or using the NuGet package manager:
16
16
17
17
```
18
18
dotnet add package Seq.Extensions.Logging
19
19
```
20
20
21
-
In `Startup.cs`, call `AddSeq()` on the provided`ILoggingBuilder`.
21
+
In `Program.cs`, call `AddSeq()` on the host's`ILoggingBuilder`.
// Use the Seq logging configuration in appsettings.json
25
+
builder.Host.ConfigureLogging(loggingBuilder=>
26
+
loggingBuilder.AddSeq());
34
27
```
35
28
36
29
The framework will inject `ILogger` instances into controllers and other classes:
@@ -54,7 +47,7 @@ class HomeController : Controller
54
47
55
48
Log messages will be sent to Seq in batches and be visible in the Seq user interface. Observe that correlation identifiers added by the framework, like `RequestId`, are all exposed and fully-searchable in Seq.
56
49
57
-
### Logging with message templates
50
+
### Logging with message templates~~~~
58
51
59
52
Seq supports the templated log messages used by _Microsoft.Extensions.Logging_. By writing events with _named format placeholders_, the data attached to the event preserves the individual property values.
60
53
@@ -109,7 +102,17 @@ In `appsettings.json` add a `"Seq"` property to `"Logging"` to configure the ser
109
102
110
103
### Dynamic log level control
111
104
112
-
The logging provider will dynamically adjust the default logging level up or down based on the level associated with an API key in Seq. For further information see the [Seq documentation](http://docs.datalust.co/docs/using-serilog#dynamic-level-control).
105
+
The logging provider will dynamically adjust the default logging level up or down based on the level associated with an API key in Seq. For further information see
106
+
the [Seq documentation](http://docs.datalust.co/docs/using-serilog#dynamic-level-control).
107
+
108
+
### Including literal JSON strings in log events
109
+
110
+
The logging provider ships with a `JsonSafeString` type that can be used to communicate to the logger that a string contains valid JSON, which can be safely included in a log event as structured data.
111
+
112
+
```csharp
113
+
varjson="{\"A\": 42}";
114
+
_logger.LogInformation("The answer is {Answer}", newJsonSafeString(json));
This package is based on a subset of the powerful [Serilog](https://serilog.net) library. Not all of the options supported by the Serilog and Seq client libraries are present in the _Seq.Extensions.Logging_ package. Migrating to the full Serilog API however is very easy:
155
+
This package is based on a subset of the powerful [Serilog](https://serilog.net) library. Not all of the options supported by the Serilog and Seq client libraries are present in
156
+
the _Seq.Extensions.Logging_ package. Migrating to the full Serilog API however is very easy:
153
157
154
158
1. Install packages _Serilog_, _Serilog.Extensions.Logging_ and _Serilog.Sinks.Seq_.
155
159
2. Follow the instructions [here](https://github.com/serilog/serilog-extensions-logging) to change `AddSeq()` into `AddSerilog()` with a `LoggerConfiguration` object passed in
0 commit comments