An extension for ReSharper and Rider IDE that highlights structured logging templates and contains some useful analyzers
The highlighting is a built-in feature starting from R#/Rider 2021.2, but the extension still contains some useful analyzers that are not (yet) implemented by JetBrains team
At the moment it supports Serilog, NLog, and Microsoft.Extensions.Logging
Look for Structured Logging
in ReSharper -> Extension manager.
JetBrains Plugins Repository
Look for Structured Logging
in Settings -> Plugins -> Browse repositories.
JetBrains Plugins Repository
- Anonymous object is not destructured
- Complex object is not destructured
- Complex object is not destructured in context
- Contextual logger mismatch
- Exception passed as a template argument
- Duplicate properties in a template
- Template should be a compile-time constant
- Prefer named properties instead of positional ones
- Inconsistent log property naming
- Inconsistent log property naming in context
- Log event messages should be fragments, not sentences
Individual analyzers can be disabled as needed either through code comments or by adding a line to a project's
.editorconfig
file.
The analyzer name can be used as-is in a ReSharper comment to disable an analyzer on a per-file or per-line basis. For example:
// ReSharper disable once TemplateIsNotCompileTimeConstantProblem
To disable an analyzer for an entire directory, you can add a line to a .editorconfig
file
(learn more). In this case, the analyzer name needs to be converted to snake_case
, prefixed
with resharper_
and suffixed with _highlighting
. For example:
resharper_template_is_not_compile_time_constant_problem_highlighting = none
Inspired by SerilogAnalyzer