dotnet-nlog-logging

Standardize NLog ILogger injection and configuration across .NET projects.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/Muhomorik/KanelBulleKapital --skill dotnet-nlog-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-nlog-logging
Source: https://github.com/Muhomorik/KanelBulleKapital/tree/main/.claude/skills/dotnet-nlog-logging
Command: npx skills add https://github.com/Muhomorik/KanelBulleKapital --skill dotnet-nlog-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide enforces consistent NLog usage across .NET projects, ensuring ILogger integration, proper DI patterns, and unified logging practices to reduce runtime errors and improve observability.

Core Features & Use Cases

  • Enforce using NLog.ILogger (not Microsoft.Extensions.Logging.ILogger) to avoid mismatches
  • Require the logger to be the first constructor parameter and resolve it via DI
  • Provide concrete patterns for logging calls, including deferred formatting and common log levels
  • Include practical examples for Autofac registration and NLog.config setup to standardize configuration across apps
  • Use cases include backend services and libraries that rely on DI and structured logging with NLog

Quick Start

Configure a .NET project to use NLog by injecting NLog.ILogger as the first constructor parameter and following the conventions outlined.

Frequently Asked Questions about dotnet-nlog-logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize NLog logging in .NET dependency injection?

Standardize NLog logging in .NET by injecting NLog.ILogger as the first constructor parameter, resolving it via DI, and applying deferred formatting. This enforces consistent logger usage and configuration across backend services and libraries.

What is the correct way to configure NLog with Autofac in a .NET application?

Configure NLog with Autofac by registering NLog.ILogger through the dependency injection container and setting up the NLog.config file. This ensures the logger is properly resolved and applied uniformly across the .NET project.

Should I use NLog.ILogger or Microsoft.Extensions.Logging.ILogger for .NET logging conventions?

Use NLog.ILogger instead of Microsoft.Extensions.Logging.ILogger to avoid interface mismatches. Enforcing the native NLog interface ensures consistent structured logging practices and direct framework integration across all project components.

What are the best practices for NLog logging calls in C# services?

Best practices for NLog logging calls include using deferred formatting to prevent unnecessary string allocations and applying appropriate log levels. Injecting the logger as the first constructor parameter guarantees consistent DI-resolved usage.

Does this NLog logging convention work with .NET libraries that use dependency injection?

Yes, these NLog logging conventions apply to typical .NET libraries and services that rely on dependency injection. The guidelines ensure the logger is resolved via DI and standardized across all dependent components.

Why should the logger be the first constructor parameter in .NET dependency injection?

The logger should be the first constructor parameter to enforce a consistent dependency injection pattern across .NET projects. This convention reduces runtime errors by clearly separating logging infrastructure from business dependencies.