Create a summary of which log messages a project writes and the parameters to improve consistency
This tool analyzes .NET projects to extract and summarize logging usage patterns. It supports the following logging APIs:
- ILogger Extension Methods: Analyzes usage of
LogInformation
,LogWarning
,LogError
,LogDebug
,LogTrace
, andLogCritical
extension methods - LoggerMessage Attribute: Detects and analyzes methods decorated with
[LoggerMessage]
attribute for high-performance logging - LoggerMessage.Define: Analyzes usage of
LoggerMessage.Define
methods for compile-time log message generation - Structured Logging: Captures parameter names and templates used in structured logging scenarios
The tool helps identify:
- Inconsistent parameter naming across log messages
- Most commonly used log parameters
- Log level distribution across your codebase
- Template patterns and message structures
create HTML/JSON report:
dotnet run --project src/LoggerUsage.Cli -- <path-to-your-sln-or-csproj> <output-file-name>.<html/json>
Example report:
run the command:
dotnet run --project src/LoggerUsage.Cli -- src/LoggerUsage.Cli/LoggerUsage.Cli.csproj report.html
and in dark mode:
To run the MCP server locally:
dotnet run --project src/LoggerUsage.Mcp
By default, the server will use the configuration in src/LoggerUsage.Mcp/appsettings.json
. You can modify this file to adjust server settings as needed.
- Add support for
ILogger.Log
method - Add support for
ILogger.BeginScope
method - Create a summary of the log messages
- Integrate AI to suggest improvements and find inconsistencies
- For LoggerMessageAttribute - find all invocations of method
- Expose as a MCP