Skip to content

High Performance Logging, XUnit ITestOutputHelper

DUONG Phu-Hiep edited this page Mar 8, 2024 · 2 revisions

https://learn.microsoft.com/en-us/dotnet/core/extensions/high-performance-logging

using Microsoft.Extensions.Logging;

public static partial class LoggerMessageDefGen
{
    [LoggerMessage(EventId = 0, Level = LogLevel.Information, Message = "Send request {message}")]
    public static partial void LogSendRequest(this ILogger logger, string message);
}
using Microsoft.Extensions.Logging;

ILoggerFactory LogFactory = LoggerFactory.Create(conf =>
{
    conf.AddConsole();
});
ILogger logger = LogFactory.CreateLogger("G");

logger.LogSendRequest("Hello World");

XUnit ITestOutputHelper

https://xunit.net/docs/capturing-output#output-in-extensions

dotnet test --logger "console;verbosity=detailed"
dotnet test -filter:DisplayName~MyTest --logger "console;verbosity=detailed"