MXLogger
A minimal Microsoft.Extensions.Logging provider for test frameworks such as xUnit, NUnit and MSTest.
Install / Use
/learn @dshe/MXLoggerREADME
MXLogger

Minimalist Microsoft Extensions Logging Provider
- .NET Standard 2.0 library
- compatible with xUnit, NUnit, MSTest and other test frameworks
- customizable formatting
- supports scopes
- supports Microsoft.Extensions.DependencyInjection
- dependencies: Microsoft.Extensions.Logging
Installation
PM> Install-Package MXLogger
Simple Example (xUnit)
using Microsoft.Extensions.Logging;
using Xunit;
namespace Xunit.Abstractions;
// This class may be used as the base class for test classes.
public abstract class XunitTestBase
{
private readonly ITestOutputHelper Output;
protected readonly ILoggerFactory LogFactory;
protected readonly ILogger Logger;
protected void Write(string format, params object[] args) =>
Output.WriteLine(string.Format(format, args) + Environment.NewLine);
protected XunitTestBase(ITestOutputHelper output, LogLevel logLevel = LogLevel.Debug, string name = "Test")
{
Output = output;
LogFactory = LoggerFactory.Create(builder => builder
.AddMXLogger(output.WriteLine)
.SetMinimumLevel(logLevel));
Logger = LogFactory.CreateLogger(name);
}
}
using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Abstractions;
namespace YourNamespace;
public class SimpleExample : XunitTestBase
{
public SimpleExample(ITestOutputHelper output) : base(output) { }
[Fact]
public void Test()
{
Logger.LogInformation("message!");
Write("test!");
}
}
output:
Info: Test
message!
test!
Dependency Injection Example (xUnit)
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Xunit.Abstractions;
public class MyComponent
{
private readonly ILogger Logger;
public MyComponent(ILogger<MyComponent> logger)
{
Logger = logger;
}
public void Run()
{
Logger.LogCritical("Message");
...
}
}
public class DependencyInjectionTest
{
private readonly MyComponent MyComponent;
public DependencyInjectionTest(ITestOutputHelper output)
{
MyComponent = new ServiceCollection()
.AddTransient<MyComponent>()
.AddLogging(builder => builder
.AddMXLogger(output.WriteLine)
.SetMinimumLevel(LogLevel.Debug))
.BuildServiceProvider()
.GetRequiredService<MyComponent>();
}
[Fact]
public void Test()
{
MyComponent.Run();
...
}
}
output:
Crit: MyNamespace.MyComponent
Message
Related Skills
gh-issues
340.5kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
84.2kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
