Vostok.Logging
HomeQuickstartModulesImplementations
1.0.0
1.0.0
  • Home
  • Quickstart
  • Guarantees
  • Configuration
  • Concepts and basics
    • Log interface
    • Log events
    • Syntax
      • Logging extensions
      • Message templates
      • Providing property values
    • Formatting
      • Output templates
      • Special properties
      • Format specifiers
    • Source context
    • Operation context
  • Modules
    • Abstractions
    • Configuration
    • Formatting
    • Console
    • File
    • Hercules
    • Context
    • Serilog
    • Log4net
    • NUnit
    • Microsoft
  • Implementations
    • Silent log
    • Console log
    • File log
    • Hercules log
  • Integrations
    • Serilog integration
    • Log4net integration
    • Microsoft logging integration
  • How-to guides
    • Using operation context
    • Using static log provider
    • Filtering events
    • Enriching events
    • Transforming events
    • Combining multiple logs
    • Custom output templates
    • External configuration rules
Powered by GitBook
On this page
  • Description
  • Source and packages
  • Details
  1. Modules

NUnit

Description

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.

Source and packages

GitHub repository: vostok/logging.nunit

NuGet package: Vostok.Logging.NUnit

Install-Package Vostok.Logging.NUnit

Cement users should reference this module with the following command:

cm ref add vostok.logging.nunit <path-to-project>

Details

Current test context

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.

AsyncLocal context

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.

PreviousLog4netNextMicrosoft

Last updated 2 years ago