Visitar URL original
Add a README to the NLog NuGet package by SparkUiX · Pull Request #6352 · NLog/NLog · GitHub
Skip to content

Add a README to the NLog NuGet package - #6352

Open
SparkUiX wants to merge 3 commits into
NLog:mainfrom
SparkUiX:codex/nlog-package-readme-6350
Open

SparkUiX wants to merge 3 commits into
NLog:mainfrom
SparkUiX:codex/nlog-package-readme-6350

Conversation

@SparkUiX

@SparkUiX SparkUiX commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

The NLog NuGet package has no README. Add a package-specific introduction, a runnable console example, capabilities, configuration choices, and documentation links, and include the README at the package root.

Following review feedback, clarify that the core package works independently of Microsoft.Extensions.Logging, describe loading the NLog section from appsettings.json through NLog.Extensions.Logging, and distinguish Logging, Generic Host, and ASP.NET Core integration packages.

Fixes #6350.

Validation

  • Baseline packaging has no README metadata; candidate packaging includes the declared README matching its source and the four default target libraries. The original submission also validated the release target set including net45 and symbol packaging.
  • Ran the literal README C# example against the candidate package on .NET 10. The unchanged example was also tested on .NET 8 in the original submission.
  • Verified AddNLog() loading the JSON NLog section with the candidate package, NLog.Extensions.Logging 6.3.0 and Microsoft.Extensions.Hosting 10.0.15; ${configsetting} and the structured Name property produce the expected output.
  • Baseline and candidate each pass all 8 AutoReloadTests on net10.0, including TestAutoReloadOnFileCopy.
  • Full net10.0 runs on both have 3046 passed, 19 failed, 8 skipped, with exactly the same 19 failing test cases (17 ColoredConsoleTarget cases and 2 FileTarget archive cases). These are baseline failures in this local environment; their root causes were not investigated as part of this README change.
  • git diff --check passes.

The existing AppVeyor build 55075248 failed AutoReloadTests.TestAutoReloadOnFileCopy; that failure was not reproduced in either local targeted or full run and is not claimed fixed or proven flaky. Both builds also emit the existing NETSDK1210 AOT-setting warning. Other operating systems, net462 runtime, and NuGet upload preview were not tested in this update. No runtime source, test code, public API, dependency or target-framework changes are included.

Disclosure

This update was prepared with AI assistance and reviewed in a separate, fresh-context Codex AI session covering the full PR. The contributor has not performed a human code review of this submission. Validation results and limitations are listed above.

Copilot AI balanced review requested due to automatic review settings November 12, 2026 12:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ec0f8c3b-5ff2-432f-aabe-6b2ad49204eb
Commits

Reviewing files that changed from the base of the PR and between 4769b1c and c17341e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change adds a README with NLog installation, configuration, usage, and support information. The project declares the README as the NuGet package readme and includes it at the package root.

Changes

Package README

Layer / File(s) Summary
README content and package inclusion
src/NLog/README.md, src/NLog/NLog.csproj
The README describes installation, console logging and shutdown, configuration options, integrations, support resources, and licensing. The project declares the README as the package readme and packs it at the package root.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: Minimal · previous review 4769b

This adds a README to the NLog NuGet package and has no runtime effect. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Add a README to the NLog NuGet package" states the main change. The PR adds README.md, declares it in NLog.csproj as the package readme, and includes it at the package root. The title is sp…
Linked Issues check Passed Issue #6350 (direct, open) asks that the NuGet package include a README. The issue body contains only an image and no written acceptance criteria, so the requirement is package-level README support. T…
Out of Scope Changes check Passed The whole-PR diff (merge base 717010c to head 4769b1c) changes two files. src/NLog/NLog.csproj adds only the README metadata property and the README pack item. The existing PackageIcon entry and the…
Description check Passed The PR description is related to the changeset. It states that the NLog NuGet package gets a new README, a console example, and documentation links, and that the README is included at the package root…
Full details: Title check

Explanation

The title "Add a README to the NLog NuGet package" states the main change. The PR adds README.md, declares it in NLog.csproj as the package readme, and includes it at the package root. The title is specific and matches the linked issue #6350 about the missing NuGet README.

Full details: Linked Issues check

Explanation

Issue #6350 (direct, open) asks that the NuGet package include a README. The issue body contains only an image and no written acceptance criteria, so the requirement is package-level README support. The whole-PR diff (merge base 717010c to head 4769b1c) meets it. src/NLog/NLog.csproj adds <PackageReadmeFile>README.md</PackageReadmeFile> to the package metadata. It also adds <None Include="README.md" Pack="true" PackagePath="" /> so the file packs at the package root. src/NLog/README.md is a new 83-line file. It contains a package introduction, a console logging example, configuration options, integration packages, and documentation links. The requirement is a documentation and packaging change. No automated tests were added. The issue does not request tests. The PR reports manual pack-level checks. This review did not repeat those checks. Changes since the previous reviewed head (8f9e301) expanded README.md from the earlier 56-line version to 83 lines. The csproj change is unchanged. The expanded content does not alter the packaging requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff (merge base 717010c to head 4769b1c) changes two files. src/NLog/NLog.csproj adds only the README metadata property and the README pack item. The existing PackageIcon entry and the DownloadMissingContent target are unchanged. src/NLog/README.md is the new package readme. Both changes implement #6350. The README content covers package capabilities, installation, a console example, configuration, integrations, and links. These topics support the README objective. The PR states that it changes no runtime source, public API, dependency, or target framework. The diff confirms this. No unrelated changes were found.

Full details: Description check

Explanation

The PR description is related to the changeset. It states that the NLog NuGet package gets a new README, a console example, and documentation links, and that the README is included at the package root. It also covers the validation performed and the AI-assistance disclosure. The description matches the raw summary of changes to NLog.csproj and README.md.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the README by the light,
Then packs it with the code just right.
Console logs hop through the page,
Config options share the stage.
With shutdown safe, the tale is done,
The package carries help for everyone.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e720eb18-8762-4f07-a332-2b49c8cb52c5
Commits

Reviewing files that changed from the base of the PR and between 8f9e301 and 4769b1c.

Files selected for processing: 1

  • src/NLog/README.md
Files skipped from review as they are similar to previous changes: 1

  • src/NLog/README.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread src/NLog/README.md Outdated
}
```

NLog can also load logging rules, targets, and layouts from an XML configuration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also mention that NLog configuration can be loaded from appsettings.json-file with help from NLog.Extensions.Logging.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a configuration section covering Fluent, XML, and loading the NLog section from appsettings.json through NLog.Extensions.Logging, with a link to the setup examples. Also incorporated the broader suggestions by clarifying core-package independence, capabilities, and the Logging/Hosting/ASP.NET Core package roles.

Verified the README example and a JSON/AddNLog configuration with ${configsetting} and structured properties against the candidate package. The AppVeyor TestAutoReloadOnFileCopy failure was not reproduced: all 8 AutoReloadTests pass on both baseline and candidate. Full local net10.0 runs have the same 19 baseline failures on each side (details in the PR body); I am not claiming the hosted CI failure is fixed.

This update and the full PR were reviewed in a separate, fresh-context Codex AI session; the contributor has not performed a human code review.

@snakefoot

snakefoot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Since written by AI,then I guess a evaluation from AI is valid:

That distinction matters for three audiences:

- Developers: They want to know why they should choose NLog, how quickly they can get started, and how it fits into their existing application.

- Experienced .NET developers: They want to see structured logging, configuration, ASP.NET Core integration, performance, extensibility, and production capabilities.

- AI assistants and coding agents: They need clear package relationships, correct installation instructions, recognizable integration scenarios, and working examples they can confidently recommend and generate code for.

I would also address your observation about appsettings.json immediately. Its absence is quite noticeable in a modern .NET README.

There is one important architectural distinction: NLog itself is the core logging package, while NLog.Extensions.Logging provides the Microsoft.Extensions.Logging integration and the associated .NET configuration integration. We should explain that distinction without making users feel that they need to understand the entire NLog ecosystem before getting started.
What I would improve
1. Sell the capabilities, not just the package

The opening sentence is technically correct but undersells NLog.

I would introduce the main capabilities immediately:

- Structured logging with message templates and event properties.
- Flexible routing to multiple destinations (targets).
- Powerful formatting and enrichment (layouts and layout renderers).
- XML, JSON/appsettings.json, and fluent programmatic configuration.
- Asynchronous and buffered logging.
- Extensive extensibility through first-party and community extensions.
- Integration with Microsoft.Extensions.Logging and ASP.NET Core.

These are actual reasons to choose NLog, rather than merely describing what a logging library does.

The official NLog website already communicates several of these capabilities, so the NuGet README should reinforce that message.

2. Make appsettings.json a first-class citizen

I would explicitly mention three configuration approaches:

Configuration
- NLog Fluent API / code
- NLog NLog.config (XML)
- NLog appsettings.json
	
NLog.Extensions.Logging or NLog.Web.AspNetCore

This is important because developers increasingly expect configuration through the standard .NET configuration system.

In particular, NLog supports:

- The NLog section in appsettings.json.
- Environment-specific configuration overrides.
- Environment variables.
- ${configsetting} for accessing application configuration values.

There is an important nuance: NLog 5 and newer can automatically discover the NLog configuration section when integrated through AddNLog() or UseNLog(). 
NLog/NLog.Extensions.Logging GitHub Wiki
+2
3. Make the integration story clearer

The current integrations section is too small for the importance of the .NET ecosystem.

I would distinguish:

- NLog – standalone logging API, targets, layouts, configuration and logging engine.
- NLog.Extensions.Logging – Microsoft ILogger integration and appsettings.json configuration.
- NLog.Extensions.Hosting – Generic Host integration.
- NLog.Web.AspNetCore – ASP.NET Core integration, including web-specific functionality.

This also helps prevent a common misconception: that NLog requires Microsoft.Extensions.Logging.

It doesn't. The core NLog package works perfectly well independently. 

4. Show what makes NLog powerful

The current example demonstrates logging one message to the console.

That's a good first example, but it doesn't communicate the real strengths of NLog.

I'd add a short feature-oriented section explaining:

- One log event can be routed to multiple targets.
- Log levels and filtering rules can be configured independently.
- Log events retain structured properties.
- Layouts allow the same event to be rendered differently for different destinations.
- Targets can be extended with additional packages.
- Logging can be asynchronous and buffered.

The important thing is not to turn the README into a manual. One or two sentences per capability are enough.

5. Improve discoverability for AI coding agents

This is becoming increasingly important.

An AI assistant often needs to answer questions such as:

- Which NuGet package should I install?
- Can I use NLog without Microsoft.Extensions.Logging?
- How do I configure NLog using appsettings.json?
- How do I configure file logging?
- How do I use NLog with ASP.NET Core?
- How do I write structured log messages?
- Where do I find available targets?

The README should answer these questions explicitly, using the exact package names and recognizable API names.

I'd also make the distinction between core NLog and the integration packages unmistakable. This reduces the risk of AI-generated code recommending unnecessary packages or using APIs from the wrong package.

One additional thought: don't optimize exclusively for AI. A well-structured README with accurate package relationships, copyable examples and clear terminology is also exactly what human developers need.
My suggested revised README.md

I would aim for something like the following. It stays relatively compact, but communicates considerably more value.

NLog is a flexible, high-performance logging platform for .NET.

Create, capture, enrich, format, filter, and route log events to multiple destinations with powerful structured logging and flexible configuration.

NLog works with standalone .NET applications as well as the Microsoft.Extensions.Logging ecosystem, including ASP.NET Core. Start with console and file logging, then extend your logging infrastructure with hundreds of available targets, layouts, and extensions.
Why NLog?

- Structured logging – Capture message-template properties, event properties, and contextual information.
- Flexible routing – Send log events to multiple destinations with configurable rules and filters.
- Powerful formatting – Customize log output using layouts and layout renderers, including JSON and other structured formats.
- Multiple configuration options – Configure logging using fluent APIs, XML configuration (NLog.config), or JSON configuration (appsettings.json).
- Extensible architecture – Add logging destinations, layout renderers, filters, and other functionality through extension packages.
- Asynchronous logging – Improve application responsiveness with asynchronous and buffered targets.
- .NET ecosystem integration – Integrate with Microsoft.Extensions.Logging, dependency injection, Generic Host, and ASP.NET Core.

Getting started

Install NLog in your application:

dotnet add package NLog

Configure console logging using the fluent configuration API:
csharp

using NLog;

var logger = LogManager.Setup()
    .LoadConfiguration(builder => builder.ForLogger().WriteToConsole())
    .GetCurrentClassLogger();

try
{
    logger.Info("Hello, {Name}!", "World");
}
finally
{
    LogManager.Shutdown();
}

NLog supports both structured logging and traditional logging. Message-template properties are captured as structured event properties and can be used when formatting or routing log events.
Configuration

NLog offers several ways to configure logging depending on your application's architecture and preferences.
Fluent configuration

Configure targets, logging rules, and layouts directly in C# using the fluent configuration API.

See Fluent Configuration API.
XML configuration

Use an NLog.config file to define logging targets, rules, and layouts separately from application code.

See Configuration File.
JSON configuration (appsettings.json)

For applications using Microsoft.Extensions.Logging, NLog can load its logging configuration from the NLog section in appsettings.json.

Install the integration package:

dotnet add package [NLog.Extensions.Logging](https://www.nuget.org/packages/NLog.Extensions.Logging)

NLog supports environment-specific configuration, environment variable overrides, and accessing application configuration values through the ${configsetting} layout renderer.

See NLog configuration with appsettings.json.

Integrations

NLog works independently or integrates with the wider .NET ecosystem.

- Microsoft.Extensions.Logging: NLog.Extensions.Logging – Use NLog as a provider for Microsoft's ILogger abstraction, with structured logging, scopes, and appsettings.json configuration.
- .NET Generic Host: [NLog.Extensions.Hosting](https://www.nuget.org/packages/NLog.Extensions.Hosting) – Integrate NLog with the .NET Generic Host.
- ASP.NET Core: [NLog.Web.AspNetCore](https://www.nuget.org/packages/NLog.Web.AspNetCore) – Integrate NLog with ASP.NET Core applications, including web-specific logging capabilities.

Targets and extensions

NLog includes built-in console and file targets. Additional logging destinations are available through extension packages.

Explore available [NLog Targets, Layouts, and Extensions](https://nlog-project.org/config/?tab=targets).
Documentation and support

- [Getting started tutorials](https://github.com/NLog/NLog/wiki/Tutorial)
- [Structured logging](https://github.com/NLog/NLog/wiki/How-to-use-structured-logging)
- [Configuration options](https://nlog-project.org/config/)
- [API reference](https://nlog-project.org/documentation/)
- [Troubleshooting](https://github.com/NLog/NLog/wiki/Logging-troubleshooting)
- [Release notes](https://github.com/NLog/NLog/releases)
- [Report an issue](https://github.com/NLog/NLog/issues)

Community and contributions

NLog is an open-source project maintained by contributors and supported by its community.

Contributions, bug reports, feature requests, and feedback are welcome! See Contributing to NLog.

NLog is licensed under the [BSD 3-Clause license](https://github.com/NLog/NLog/blob/main/LICENSE.txt).
A few additional recommendations before merging

There are some things I would specifically discuss with the other maintainer.

1. Consider an appsettings.json example in addition to the link.

This is probably the biggest opportunity. Even a small JSON example would make the README more discoverable and useful to developers and AI agents.

2. Don't overload the README with every feature.

NLog has an enormous ecosystem. The README should communicate the breadth of capabilities, while the configuration website should explain the individual targets, layouts, and extensions.

3. Consider mentioning AOT compatibility.

NLog 6 introduced Native AOT support. This is a valuable modern .NET capability worth mentioning, provided the README links to the relevant compatibility documentation. 
GitHub

4. Keep the README synchronized with the actual NuGet package.

This is particularly important for the package installation commands, supported frameworks, and API examples. A README that generates outdated AI answers is worse than a shorter README.

5. Think about the relationship between the READMEs.

I would establish a consistent style across:

- NLog

- NLog.Extensions.Logging

- NLog.Extensions.Hosting

- NLog.Web.AspNetCore

Each package should explain its own responsibility, while linking to the others. Avoid repeating the entire NLog introduction in every package.

My overall recommendation

I would actually make one strategic change to how NLog presents itself:

Stop positioning NLog primarily as a logging library. Position it as a logging platform.

The distinction is meaningful. NLog isn't just an API for writing messages to files. It is an extensible logging engine with structured events, routing, filtering, enrichment, formatting, configuration, integrations, and a broad ecosystem of destinations.

That's the value proposition that should come through when a developer, an architect, or an AI assistant encounters NLog for the first time.

And one final thought: NuGet README files are increasingly becoming the first documentation an AI coding assistant encounters when deciding which package to recommend. I would treat every NLog package README as both a human-facing introduction and a concise, accurate source of technical knowledge for AI.

Inspirational version from other AI

NLog

NLog is a flexible, high-performance logging platform for .NET.

Create, capture, enrich, format, filter, and route log events to multiple destinations with powerful structured logging and flexible configuration.

NLog works with standalone .NET applications as well as the Microsoft.Extensions.Logging ecosystem, including ASP.NET Core. Start with console and file logging, then extend your logging infrastructure with hundreds of available targets, layouts, and extensions.

Why NLog?

  • Structured logging – Capture message-template properties, event properties, and contextual information.
  • Flexible routing – Route log events to multiple destinations using configurable logging rules, targets, and filters.
  • Powerful formatting – Customize log output using layouts and layout renderers, including JSON and other structured formats.
  • High performance – Designed for efficient logging with low overhead, deferred message formatting, asynchronous processing with minimal lock congestion.
  • Powerful configuration – Configure logging using fluent APIs, XML configuration (NLog.config), or JSON configuration (appsettings.json).
  • Environment-aware logging – Adapt logging configuration to Development, Staging, and Production environments using configuration overrides, environment variables, conditional includes, and layout renderers.
  • Dynamic logging control – Change logging thresholds and routing behavior at runtime, enable temporary diagnostic logging, and apply sophisticated filtering without restarting your application.
  • Extensible architecture – Add logging destinations, layout renderers, filters, and other functionality through extension packages.
  • .NET ecosystem integration – Integrate with Microsoft.Extensions.Logging, dependency injection, Generic Host, and ASP.NET Core.

Getting started

Install NLog in your application:

dotnet add package NLog

Configure console logging using the fluent configuration API:

using NLog;

var logger = LogManager.Setup()
    .LoadConfiguration(builder => builder.ForLogger().WriteToConsole())
    .GetCurrentClassLogger();

try
{
    logger.Info("Hello, {Name}!", "World");
}
finally
{
    LogManager.Shutdown();
}

NLog supports both structured logging and traditional logging. Message-template properties are captured as structured event properties and can be used when formatting or routing log events.

Configuration

NLog offers several ways to configure logging depending on your application's architecture and preferences.

Fluent configuration

Configure targets, logging rules, and layouts directly in C# using the fluent configuration API.

See Fluent Configuration API.

XML configuration

Use an NLog.config file to define logging targets, rules, and layouts separately from application code.

See Configuration File.

JSON configuration (appsettings.json)

For applications using Microsoft.Extensions.Logging, NLog can load its logging configuration from the NLog section in appsettings.json.

Install the integration package:

dotnet add package NLog.Extensions.Logging

NLog supports environment-specific configuration, environment variable overrides, and accessing application configuration values through the ${configsetting} layout renderer.

See NLog configuration with appsettings.json.

Integrations

NLog works independently or integrates with the wider .NET ecosystem.

  • Microsoft.Extensions.Logging: NLog.Extensions.Logging – Use NLog as a provider for Microsoft's ILogger abstraction, with structured logging, scopes, and appsettings.json configuration.
  • .NET Generic Host: NLog.Extensions.Hosting – Integrate NLog with the .NET Generic Host.
  • ASP.NET Core: NLog.Web.AspNetCore – Integrate NLog with ASP.NET Core applications, including web-specific logging capabilities.

Targets and extensions

NLog includes built-in console and file targets. Additional logging destinations are available through extension packages.

Explore available NLog Targets, Layouts, and Extensions.

Documentation and support

Community and contributions

NLog is an open-source project maintained by contributors and supported by its community.

Contributions, bug reports, feature requests, and feedback are welcome!

See Contributing to NLog.

License

NLog is licensed under the BSD 3-Clause license.

@304NotModified

Copy link
Copy Markdown
Member

FYI the CI has been updated (see #6328) and I added a merge commit to this branch.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.61%. Comparing base (e157caf) to head (c17341e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6352      +/-   ##
==========================================
- Coverage   73.62%   73.61%   -0.01%     
==========================================
  Files         341      341              
  Lines       20795    20795              
  Branches     5282     5282              
==========================================
- Hits        15310    15308       -2     
- Misses       3829     3830       +1     
- Partials     1656     1657       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NuGet package is missing a README

4 participants