R8.XunitLogger
1.1.1
See the version list below for details.
dotnet add package R8.XunitLogger --version 1.1.1
NuGet\Install-Package R8.XunitLogger -Version 1.1.1
<PackageReference Include="R8.XunitLogger" Version="1.1.1" />
paket add R8.XunitLogger --version 1.1.1
#r "nuget: R8.XunitLogger, 1.1.1"
// Install R8.XunitLogger as a Cake Addin #addin nuget:?package=R8.XunitLogger&version=1.1.1 // Install R8.XunitLogger as a Cake Tool #tool nuget:?package=R8.XunitLogger&version=1.1.1
R8.XunitLogger
Seamlessly integrate Xunit's ITestOutputHelper
with Microsoft.Extensions.Logging
using netstandard2.1
, net6.0
, net7.0
and net8.0
. Capture logs from any layer of your application and send them to your test output, making debugging and integration testing a breeze. With minimal configuration, you can monitor log messages, helping to ensure your application runs smoothly.
Installation
dotnet add package R8.XunitLogger
Options
Option | Description | Default Value |
---|---|---|
MinimumLevel | The minimum level of log messages to be written to the test output | LogLevel.Information |
IncludeTimestamp | Whether to include timestamp in log messages | true |
IncludeScopes | Whether to include scopes in log messages | false |
ColorBehavior | Whether to enable colored log levels | LoggerColorBehavior.Default |
Categories | The categories (namespaces) of log messages to be written to the test output | null |
ServiceProvider | The service provider to be get appsettings.json from IConfiguration |
null |
Colored Log Levels
Microsoft Visual Studio
does not support colored log levels. However, JetBrains Rider
does support colored log levels. If you want to enable colored log levels, you can use LoggerColorBehavior
enum.
If the value is set to LoggerColorBehavior.Default
, the log levels will be colored in JetBrains Rider
and will not be colored in Microsoft Visual Studio
.
Usage
For unit testing:
public class UnitTest
{
public UnitTest(ITestOutputHelper outputHelper)
{
_loggerFactory = new LoggerFactory().AddXunit(outputHelper, options =>
{
// ... options
});
}
}
For integration testing:
public class IntegrationTest : IXunitLogProvider
{
public IntegrationTest(ITestOutputHelper outputHelper)
{
var serviceProvider = new ServiceCollection()
.AddLogging()
.AddXunitForwardingLoggerProvider(message => OnWriteLine?.Invoke(message), options =>
{
// ... options
})
.BuildServiceProvider();
this.OnWriteLine += outputHelper.WriteLine;
}
public event Action<string> OnWriteLine;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- xunit.abstractions (>= 2.0.3)
-
net6.0
- Microsoft.Extensions.Configuration (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- xunit.abstractions (>= 2.0.3)
-
net7.0
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- xunit.abstractions (>= 2.0.3)
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- xunit.abstractions (>= 2.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.