rm-guide-logging

Standardize structured ILogger logging with LoggerMessage definitions in C# services.

Updated Nov 11, 2023
One-click install
npx skills add https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb --skill rm-guide-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rm-guide-logging
Source: https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb/tree/main/.opencode/skills/redmuffin-standards/rm-guide-logging
Command: npx skills add https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb --skill rm-guide-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill keeps logging consistent and secure by guiding developers to use structured ILogger patterns and to avoid scattering LoggerMessage definitions that end up logging sensitive data.

Core Features & Use Cases

  • Structured ILogger use: encourages parameterized, short log messages and emphasizes logging outcomes over noisy internal state.
  • LoggerMessage placement: mandates placing LoggerMessage declarations in dedicated *.Logging.cs files while preferring them in hot paths instead of manual LogError/LogInformation calls.
  • Use Case: When adding observability to new services, functions, or handlers, rely on these standards to keep logs performant and maintainable.

Quick Start

Add structured logging with LoggerMessage definitions for your new handler using rm-guide-logging.

Frequently Asked Questions about rm-guide-logging

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

FAQPage Schema
How do I use structured logging with ILogger in .NET hot paths?

Structured ILogger logging in .NET uses parameterized messages and LoggerMessage definitions to capture log data consistently. It emphasizes logging outcomes over noisy internal state and standardizes declarations in *.Logging.cs files to keep output safe and maintainable.

Why should I place LoggerMessage declarations in a separate file?

Placing LoggerMessage declarations in dedicated *.Logging.cs files prevents scattering definitions across the codebase. This placement keeps logging clean, avoids scattering sensitive data in logs, and maintains consistency across C# services, functions, and handlers that need observability.

What is the best way to avoid logging secrets in .NET services?

To avoid logging secrets in .NET services, use parameterized structured ILogger messages and standardize LoggerMessage definitions. This approach enforces logging outcomes over internal state and keeps sensitive data out of log output across services, functions, and handlers.

How do I add observability to a new C# handler with consistent logging?

To add observability to a new C# handler, use structured ILogger patterns and define LoggerMessage declarations in *.Logging.cs files. This ensures consistent, secure log output by favoring parameterized messages and avoiding manual logging calls in hot paths.

When do I need LoggerMessage definitions instead of manual LogInformation calls?

You need LoggerMessage definitions in .NET hot paths instead of manual LogInformation or LogError calls to ensure consistent structured logging. LoggerMessage declarations provide better performance and standardization, especially when adding observability to frequently executed service or handler code.