Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trbenning/serilog-sinks-xunit
The xunit test output sink for Serilog
https://github.com/trbenning/serilog-sinks-xunit
Last synced: 2 months ago
JSON representation
The xunit test output sink for Serilog
- Host: GitHub
- URL: https://github.com/trbenning/serilog-sinks-xunit
- Owner: trbenning
- License: mit
- Created: 2017-02-28T21:30:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-27T21:21:31.000Z (over 1 year ago)
- Last Synced: 2024-05-28T12:53:33.901Z (8 months ago)
- Language: C#
- Size: 56.6 KB
- Stars: 78
- Watchers: 4
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Nuget-Packages - **Serilog.Sinks.XUnit**
README
[![Build Status](https://dev.azure.com/benning/Serilog.Sinks.XUnit/_apis/build/status/trbenning.serilog-sinks-xunit?branchName=master)](https://dev.azure.com/benning/Serilog.Sinks.XUnit/_build/latest?definitionId=2&branchName=master)
[![NuGet Version](https://img.shields.io/nuget/v/Serilog.Sinks.XUnit.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.XUnit/)# serilog-sinks-xunit
The xunit test output sink for Serilog### What is it?
It's a package that will allow you to use Serilog for test output.### Installation
```
Install-Package Serilog.Sinks.XUnit
```### Example usage
```csharp
using System;
using Xunit;
using Xunit.Abstractions;public class Samples
{
ILogger _output;public Samples(ITestOutputHelper output)
{
// Pass the ITestOutputHelper object to the TestOutput sink
_output = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.TestOutput(output, Events.LogEventLevel.Verbose)
.CreateLogger()
.ForContext();
}[Fact]
public void ExampleUsage()
{
// Use ILogger as you normally would. These messages will show up in the test output
_output.Information("Test output to Serilog!");Action sketchy = () => throw new Exception("I threw up.");
var exception = Record.Exception(sketchy);_output.Error(exception, "Here is an error.");
Assert.NotNull(exception);
}
}
```