resharper-structured-logging icon indicating copy to clipboard operation
resharper-structured-logging copied to clipboard

An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers

ReSharper Structured Logging

Build status Quality Gate Status

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

Installation ReSharper

Look for Structured Logging in ReSharper -> Extension manager.
JetBrains Plugins Repository

Installation Rider

Look for Structured Logging in Settings -> Plugins -> Browse repositories.
JetBrains Plugins Repository

Highlighting

Highlighting

Analyzers

  • 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

Credits

Inspired by SerilogAnalyzer