Introduction

edit

The logging packages of Meziantou.Framework are providers for Microsoft.Extensions.Logging. Your code keeps logging through ILogger and ILogger<T>; the provider decides where the entries go.

PackageWrites the entries toTypical use
Meziantou.Extensions.Logging.FileLoggerFiles on disk, written by a background threadApplications and services
Meziantou.Extensions.Logging.InMemoryA collection in memoryTests that assert on the logs
Meziantou.Extensions.Logging.Xunit.v3The output of the running xUnit.net v3 testTests that show the logs of the code under test

Each package is independent: install only the ones you need. The test packages are often used together: the in-memory logger to assert on the entries, and the xUnit.net logger to read them when a test fails.

What you can do with them

  • Write the logs to files without blocking the application, with one file per hour, day or month, a size limit, retention and compression. See File logger.
  • Assert on the logs in tests: find the entries by level, message, category or parameter value. See In-memory logger.
  • Show the logs in the test output, for the test that is running, including from a host or a web application started by the test. See xUnit.net logger.

Namespaces

PackageNamespace
Meziantou.Extensions.Logging.FileLoggerMeziantou.Extensions.Logging
Meziantou.Extensions.Logging.InMemoryMeziantou.Extensions.Logging.InMemory
Meziantou.Extensions.Logging.Xunit.v3Meziantou.Extensions.Logging.Xunit.v3

LoggerFactory, ILogger and the LogInformation extension methods are in the Microsoft.Extensions.Logging namespace.

Next steps