Test and Observable loggers for Microsoft.Extensions.Logging.
var logCollector = new LogCollector();
using(logCollector.CollectLogs())
{
ILogger logger = logCollector.Logger;
// code that uses logger instance.
}
Assert.AreEquals(5, logCollector.Logs);
var logCollector = new LogCollector<MyClass>();
using(logCollector.CollectLogs())
{
ILogger<MyClass> logger = logCollector.Logger;
// code that uses logger instance.
}
Assert.AreEquals(5, logCollector.Logs);
using (var subject = new Subject<LogEvent>();
using (var logger = new ObservableLogger("Category", (a,b) => true, subject))
{
subject.Dump();
// code that uses logger instance.
Console.ReadLine();
}