talira

Flexible, structured logging for .NET

open sourceBSD-3-Clausefree

NLog is a logging library for .NET that writes to many targets at once (console, files, databases and more) and supports both structured logging with message templates and traditional text logging. It's configured in an NLog.config file, appsettings.json or code, and the configuration can change while the app runs. Layouts format output as plain text, JSON, XML or CSV, and it plugs into Microsoft.Extensions.Logging and ASP.NET Core without replacing the standard LoggerFactory.

Problems it solves

  • log to files, a database and the console at once in a .NET app
  • structured logging in ASP.NET Core without replacing Microsoft's logger
  • change logging configuration without restarting the app

Features

  • many targets: console, file, database and more
  • structured and traditional logging
  • JSON, XML and CSV layouts
  • configuration from NLog.config, appsettings.json or code, changeable at runtime
  • Microsoft.Extensions.Logging and ASP.NET Core integration
  • custom targets and layouts

Alternatives

The same job

These do what NLog does.

  1. Serilog Simple .NET logging with fully structured events
  2. Apache log4net A logging library for .NET

Compare NLog with the top 3