dotnet-source-gen-logging

Convert inline ILogger calls into LoggerMessage-based extension methods.

6|2|Updated Aug 14, 2025
One-click install
npx skills add https://github.com/Im5tu/claude --skill dotnet-source-gen-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-source-gen-logging
Source: https://github.com/Im5tu/claude/tree/main/skills/dotnet-source-gen-logging
Command: npx skills add https://github.com/Im5tu/claude --skill dotnet-source-gen-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Converts inline ILogger usage into LoggerMessage-based extensions to reduce allocations and enable compile-time template parsing for high-performance logging.

Core Features & Use Cases

  • Convert inline LogInformation and other Log methods to generated LoggerMessage methods for major performance gains.
  • Organize log messages by domain into partial static classes with EventIds for traceability.
  • Prepare code for Native AOT deployments and consistent logging templates across projects.

Quick Start

Convert a typical logging call to a generated LoggerMessage method and switch to the corresponding extension method. Example: _logger.LogInformation("User {UserId} logged in", userId) -> _logger.UserLoggedIn(userId).

Frequently Asked Questions about dotnet-source-gen-logging

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

FAQPage Schema
How do I convert inline ILogger calls to LoggerMessage source generators in .NET?

Converting inline ILogger calls to LoggerMessage extensions generates partial static classes with EventIds, replacing standard _logger.Log calls with typed methods like _logger.UserLoggedIn(userId) to achieve compile-time template parsing.

How does LoggerMessage attribute logging improve performance in .NET hot paths?

LoggerMessage attribute logging improves .NET hot path performance by generating static extension methods at compile time, which avoids runtime template parsing, prevents memory allocations from boxing, and enables AOT-friendly deployments.

Does .NET LoggerMessage source generation work for Native AOT deployments?

Yes, LoggerMessage source generation works for Native AOT deployments because it shifts template parsing to compile time using partial static classes and attributes, eliminating dynamic IL generation and boxing overhead at runtime.

What is the best way to organize LoggerMessage methods by domain in .NET?

The best way to organize LoggerMessage methods by domain is generating partial static classes with LoggerMessage attributes, assigning unique EventIds per category to group related log messages together for traceability across .NET projects.

Do I need the .NET 6 SDK to use LoggerMessage source generators?

Yes, you need the .NET 6+ SDK to use LoggerMessage source generators, as the LoggerMessage attribute and compile-time source generation features require this baseline framework version to create AOT-ready logging extensions.