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
Please refer to the [Serilog Code of Conduct](https://github.com/serilog/serilog/blob/dev/CONTRIBUTING.md) which covers all repositories within the Serilog Organisation.
3
+
Please refer to the [Serilog Code of Conduct](https://github.com/serilog/serilog/blob/dev/CODE_OF_CONDUCT.md) which covers all repositories within the Serilog Organization.
Copy file name to clipboardExpand all lines: README.md
+35-22Lines changed: 35 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ A Serilog sink that writes log events to the Windows Console or an ANSI terminal
6
6
7
7
To use the console sink, first install the [NuGet package](https://nuget.org/packages/serilog.sinks.console):
8
8
9
-
```powershell
10
-
Install-Package Serilog.Sinks.Console
9
+
```shell
10
+
dotnet add package Serilog.Sinks.Console
11
11
```
12
12
13
13
Then enable the sink using `WriteTo.Console()`:
@@ -64,14 +64,14 @@ The default template, shown in the example above, uses built-in properties like
64
64
65
65
The sink can write JSON output instead of plain text. `CompactJsonFormatter` or `RenderedCompactJsonFormatter` from [Serilog.Formatting.Compact](https://github.com/serilog/serilog-formatting-compact) is recommended:
66
66
67
-
```powershell
68
-
Install-Package Serilog.Formatting.Compact
67
+
```shell
68
+
dotnet add package Serilog.Formatting.Compact
69
69
```
70
70
71
71
Pass a formatter to the `Console()` configuration method:
Output theming is not available when custom formatters are used.
@@ -80,8 +80,8 @@ Output theming is not available when custom formatters are used.
80
80
81
81
To use the console sink with the [Serilog.Settings.AppSettings](https://github.com/serilog/serilog-settings-appsettings) package, first install that package if you haven't already done so:
82
82
83
-
```powershell
84
-
Install-Package Serilog.Settings.AppSettings
83
+
```shell
84
+
dotnet add package Serilog.Settings.AppSettings
85
85
```
86
86
87
87
Instead of configuring the logger in code, call `ReadFrom.AppSettings()`:
@@ -101,12 +101,21 @@ In your application's `App.config` or `Web.config` file, specify the console sin
101
101
<addkey="serilog:write-to:Console" />
102
102
```
103
103
104
+
To configure the console sink with a different theme and include the `SourceContext` in the output, change your `App.config`/`Web.config` to:
To use the console 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:
107
116
108
-
```powershell
109
-
Install-Package Serilog.Settings.Configuration
117
+
```shell
118
+
dotnet add package Serilog.Settings.Configuration
110
119
```
111
120
112
121
Instead of configuring the sink directly in code, call `ReadFrom.Configuration()`:
@@ -122,7 +131,6 @@ var logger = new LoggerConfiguration()
122
131
```
123
132
124
133
In your `appsettings.json` file, under the `Serilog` node, :
125
-
126
134
```json
127
135
{
128
136
"Serilog": {
@@ -131,18 +139,23 @@ In your `appsettings.json` file, under the `Serilog` node, :
131
139
}
132
140
```
133
141
134
-
### Upgrading from _Serilog.Sinks.Console_ 2.x
135
-
136
-
To achieve output identical to version 2 of this sink, specify a formatter and output template explicitly:
This will bypass theming and use Serilog's built-in message template formatting.
145
-
146
159
### Contributing
147
160
148
161
Would you like to help make the Serilog console sink even better? We keep a list of issues that are approachable for newcomers under the [up-for-grabs](https://github.com/serilog/serilog-sinks-console/issues?labels=up-for-grabs&state=open) label. Before starting work on a pull request, we suggest commenting on, or raising, an issue on the issue tracker so that we can help and coordinate efforts. For more details check out our [contributing guide](CONTRIBUTING.md).
@@ -155,7 +168,7 @@ When contributing please keep in mind our [Code of Conduct](CODE_OF_CONDUCT.md).
155
168
Branch | AppVeyor | Travis
156
169
------------- | ------------- |-------------
157
170
dev | [](https://ci.appveyor.com/project/serilog/serilog-sinks-console/branch/dev) | [](https://travis-ci.org/serilog/serilog-sinks-console)
0 commit comments