Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Writes Serilog events to the debug output window (in `DEBUG` builds only)

License

NotificationsYou must be signed in to change notification settings

serilog/serilog-sinks-debug

Repository files navigation

A Serilog sink that writes log events toSystem.Diagnostics.Debug (i.e. the Visual Studio debug output window), inDEBUG builds only.

Getting started

To use the sink, first install theNuGet package:

dotnet add package Serilog.Sinks.Debug

Then enable the sink usingWriteTo.Debug():

Log.Logger=newLoggerConfiguration().WriteTo.Debug().CreateLogger();Log.Information("Hello, world!");

Log events will be printed to the debug output:

Debug Output

XML<appSettings> configuration

To use the sink with theSerilog.Settings.AppSettings package, first install that package if you haven't already done so:

Install-Package Serilog.Settings.AppSettings

Instead of configuring the logger in code, callReadFrom.AppSettings():

varlog=newLoggerConfiguration().ReadFrom.AppSettings().CreateLogger();

In your application'sApp.config orWeb.config file, specify the console sink assembly under the<appSettings> node:

<configuration>  <appSettings>    <addkey="serilog:using:Debug"value="Serilog.Sinks.Debug" />    <addkey="serilog:write-to:Debug" />

JSONappsettings.json configuration

To use the console sink withMicrosoft.Extensions.Configuration, for example with ASP.NET Core or .NET Core, use theSerilog.Settings.Configuration package. First install that package if you have not already done so:

Install-Package Serilog.Settings.Configuration

Instead of configuring the sink directly in code, callReadFrom.Configuration():

varconfiguration=newConfigurationBuilder().AddJsonFile("appsettings.json").Build();varlogger=newLoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();

In yourappsettings.json file, under theSerilog node, :

{"Serilog": {"WriteTo": ["Debug"]  }}

Copyright © 2017 Serilog Contributors - Provided under theApache License, Version 2.0.

About

Writes Serilog events to the debug output window (in `DEBUG` builds only)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp