Logging

Create UTF-8 thread-safe daily rotating log files for C# RocsMiddleware services.

6|Updated Oct 27, 2025
One-click install
npx skills add https://github.com/lawless-m/claude-skills --skill logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Logging
Source: https://github.com/lawless-m/claude-skills/tree/main/Logging
Command: npx skills add https://github.com/lawless-m/claude-skills --skill logging

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Microsoft.Extensions.Logging, and includes references (resource) components.

What problem does it solves? This Skill provides a standardized, robust, and thread-safe logging solution for C# RocsMiddleware services, eliminating the need to re-implement complex logging logic. It ensures consistent UTF-8 encoding, automatic daily file rotation, and reliable error handling, saving developers time and reducing debugging complexity.

Core Features & Use Cases

  • UTF-8 Encoding & Rotation: Automatically creates UTF-8 encoded log files with daily date-based rotation ({ProgramName}_YYYY_MM_DD.log).
  • Thread-Safe Writes: Ensures safe concurrent logging from multiple threads using internal locking mechanisms.
  • Smart Path Handling: Intelligently detects and handles log directory paths, simplifying configuration.
  • Use Case: Integrate this logging skill into any new or existing C# service to immediately gain consistent, reliable, and easily manageable log outputs for monitoring and debugging, especially in high-concurrency environments.

Quick Start

Use the Logging skill to set up UTF-8 file logging for my C# service, ensuring logs are rotated daily and saved to "C:\MyService\Logs".

Frequently Asked Questions about Logging

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

FAQPage Schema
How do I set up thread-safe file logging in a C# service?

Thread-safe file logging in C# uses internal locking mechanisms to ensure concurrent writes from multiple threads don't corrupt log files. This Skill provides UTF-8 encoded, thread-safe logging with automatic daily rotation and directory-based filename inference, eliminating manual synchronization code.

Can I configure log rotation by date in C#?

Date-based log rotation automatically creates new log files daily with filenames following the pattern {ProgramName}_YYYY_MM_DD.log. This Skill handles rotation transparently, ensuring logs stay organized and manageable without manual file handling.

How do I use the --log-dir command-line option with logging?

The --log-dir option specifies where log files are written. This Skill intelligently detects and handles log directory paths, automatically creating UTF-8 encoded logs in your specified directory with smart path handling across different deployment scenarios.

Does Microsoft.Extensions.Logging support UTF-8 file output without BOM?

Microsoft.Extensions.Logging provides the framework, but UTF-8 non-BOM encoding requires explicit configuration. This Skill wraps that dependency to guarantee UTF-8 output without BOM, thread-safe writes, and daily rotation out of the box.

What happens if the log directory doesn't exist when my service starts?

Pre-initialization error reporting detects missing or invalid log directories before logging begins. This Skill reports configuration errors early, preventing silent failures and ensuring logs are written reliably from startup.

Can I adjust log levels for different severity types?

Log level control lets you filter which messages are written—Info, Warning, Error, and others. This Skill integrates log level configuration with thread-safe UTF-8 file output, giving you fine-grained control over what gets logged.