NLog is a free, open source monitoring & observability project written in C# and released under BSD-3-Clause. It has 6,546 GitHub stars, 1,379 forks and 50 open issues, and was last pushed 32 hours ago. On this registry it ranks #63 of 97 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available. It gained 2 stars over the last 3 tracked days.

What is NLog?

What it is

NLog is a free logging platform for .NET, distributed under the BSD-3-Clause license and maintained in the NLog/NLog repository on GitHub. It provides rich log routing and management capabilities, so an application can produce and manage high-quality logs regardless of its size or complexity. It lives in the .NET ecosystem, is written in C#, and targets cross-platform use across .NET Framework, .NET Core, ASP.NET Core, MAUI, and Mono. The project has been developed for fourteen years and is published as the NLog package on NuGet, with the current 6.0 line adding AOT support.

The concrete problem it solves is that applications need to emit diagnostics from many places and then get those messages to the right destination in the right shape. NLog handles both structured logging and traditional logging from any .NET language, lets callers augment entries with contextual information, and formats them according to preference before sending them to one or more targets such as a file or the console. Routing, context, and output format are therefore configuration concerns rather than code that every call site has to repeat.

Key capabilities

  • Handles structured logging and traditional logging from any .NET language.
  • Routes log entries to one or more targets, including file and console, with the base NuGet package covering those two.
  • Augments log entries with contextual information before they are written.
  • Formats output according to user preference through layouts and layout renderers.
  • Supports AOT compilation as of NLog 6.0, matching the repository's aot and aot-compatible topics.
  • Extends to other outputs through separate packages, including database, email, and HTTPS endpoint targets.
  • Allows custom extensions to be written when the existing targets and renderers are not enough.

Who uses it and how

  • .NET Framework applications that follow the tutorial and configure NLog through configuration options.
  • ASP.NET Core services that wire NLog in through the dedicated ASP.NET Core getting-started path.
  • .NET Core console applications that log to files and console using the base package.
  • Cross-platform and MAUI or Mono projects that need one logging library to cover several runtimes.
  • Teams collecting structured, JSON-oriented log entries that are later routed to the destination they choose.

Getting started

Install the NLog package from NuGet; the package provides everything needed for file and console logging, and additional output options come from separate extension packages such as database, email, and HTTPS endpoint targets. Tutorials exist for .NET Framework, ASP.NET Core, and .NET Core console applications, with the options list and API reference available on the project homepage.

When to use it — and when not to

NLog suits projects that want routing, contextual enrichment, and formatting decided in configuration instead of scattered through application code, and it covers both structured and traditional logging from a single library. A self-hoster operates only what the chosen targets require — for instance a database, an SMTP server, or an HTTPS endpoint — since those live in extension packages rather than in the base package. The evident limits are that non-file and non-console outputs need extra packages, and that AOT support arrives only with NLog 6.0, so older versions on AOT-compiled runtimes are a mismatch.

project readme (upstream, from github) — read inline

NLog

NuGet Semantic Versioning NuGet downloads

Coverage

Wiki Troubleshoot Guide

NLog is a free logging platform for .NET with rich log routing and management capabilities. It makes it easy to produce and manage high-quality logs for your application regardless of its size or complexity.

Handles both structured logging and traditional logging from any .NET language, augment with contextual information, format according to your preference and send them to one or more targets such as file or console.

Major and minor releases will be posted on project news.

Getting started

For the possible options in the config, check the Options list and API Reference

Having troubles? Check the troubleshooting guide


ℹ️ NLog 6.0 supports AOT

NLog 6.0 now available. See also List of major changes in NLog 6.0

NLog Extensions

The NLog-nuget-package provides everything needed for doing file- and console-logging. If you need other output options, then there are many NLog extension packages available (such as database, email, https-endpoint, etc.). See targets and layout renderers overview!

The NLog extension packages maintained by the NLog-project are listed here with Nuget/build status.

It is also possible to Create your own custom NLog extensions.

Questions, bug reports or feature requests?

If having issues with getting NLog working? Then please check the troubleshooting guide before asking! This will often provide you with clear error message when asking, so it is easier to solve the issue!

If having questions about how to configure NLog correctly? Then please post questions on StackOverflow (using the nlog tag)

Have you found a bug or issue with NLog functionality? Please post them on the issue list and follow these guidelines.

Frequently Asked Questions (FAQ)

See FAQ on the Wiki

License

NLog is open source software, licensed under the terms of BSD license. See LICENSE.txt for details.

Frequently asked questions

Is NLog free to use?

NLog is open source under the BSD-3-Clause licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does NLog do?

NLog - Flexible and Structured Logging for various .NET Platforms

What is NLog written in?

NLog is primarily written in C#. Its source is publicly available at https://github.com/NLog/NLog, and it has 6,546 GitHub stars.