NUnit
This library provides an implementation of ILog that can be used in NUnit tests.
An instance of NUnitLog can log into different contexts of tests depending on the requirements.
Install-Package Vostok.Logging.NUnit
cm ref add vostok.logging.nunit <path-to-project>
var settings = NUnitLogSettings.WithCurrentTestContext();
var log = new NUnitLog(settings);
This type of context writes log events to the context of the test in which the log was created.
var settings = NUnitLogSettings.WithAsyncLocalContext();
var log = new NUnitLog(settings);
This type of context writes log events to the context which is retrieved from AsyncLocal static variable. It usually contains context of the current test, but in some cases (which involve launching something on a different thread, like a service, for instance) may write to the unknown context, therefore leading to losing logs.
It is recommended to create log instances using Current test context in such cases.
Last modified 5mo ago