https://github.com/serilog/serilog-sinks-debug
Writes Serilog events to the debug output window
https://github.com/serilog/serilog-sinks-debug
Last synced: 3 months ago
JSON representation
Writes Serilog events to the debug output window
- Host: GitHub
- URL: https://github.com/serilog/serilog-sinks-debug
- Owner: serilog
- License: apache-2.0
- Created: 2017-08-27T20:44:46.000Z (almost 8 years ago)
- Default Branch: dev
- Last Pushed: 2024-08-18T13:20:18.000Z (11 months ago)
- Last Synced: 2025-03-29T16:03:38.601Z (3 months ago)
- Language: C#
- Size: 92.8 KB
- Stars: 39
- Watchers: 13
- Forks: 11
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Serilog.Sinks.Debug [](https://ci.appveyor.com/project/serilog/serilog-sinks-debug) [](https://www.nuget.org/packages/Serilog.Sinks.Debug/) [](http://stackoverflow.com/questions/tagged/serilog)
A Serilog sink that writes log events to the Visual Studio debug output window.
### Getting started
To use the sink, first install the [NuGet package](https://nuget.org/packages/serilog.sinks.debug):
```powershell
dotnet add package Serilog.Sinks.Debug
```Then enable the sink using `WriteTo.Debug()`:
```csharp
Log.Logger = new LoggerConfiguration()
.WriteTo.Debug()
.CreateLogger();
Log.Information("Hello, world!");
```Log events will be printed to the debug output:

### XML `` configuration
To use the 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:
```powershell
Install-Package Serilog.Settings.AppSettings
```Instead of configuring the logger in code, call `ReadFrom.AppSettings()`:
```csharp
var log = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();
```In your application's `App.config` or `Web.config` file, specify the console sink assembly under the `` node:
```xml
```### JSON `appsettings.json` configuration
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:
```powershell
Install-Package Serilog.Settings.Configuration
```Instead of configuring the 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": ["Debug"]
}
}
```_Copyright © 2017 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html)._