ScyberLog.Analyzers 2.0.0

dotnet add package ScyberLog.Analyzers --version 2.0.0
                    
NuGet\Install-Package ScyberLog.Analyzers -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ScyberLog.Analyzers" Version="2.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ScyberLog.Analyzers" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ScyberLog.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ScyberLog.Analyzers --version 2.0.0
                    
#r "nuget: ScyberLog.Analyzers, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ScyberLog.Analyzers@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ScyberLog.Analyzers&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ScyberLog.Analyzers&version=2.0.0
                    
Install as a Cake Tool

ScyberLog.Analyzers

This repository contains a single analyzer to determine if a call to one of the logging methods defined on Microsoft.Extensions.Logging.ILogger has an invalid messaage template string. If the template is invalid, it will throw a runtime FormatException which is obviously bad because:

  1. Your logging framework should not be crashing your app.
  2. Much logging only ocurrs on the sad path, inside exception handlers, which is a place you do not want additional exceptions thrown.
  3. Some log calls may only occur rarely (as on particular exceptions), setting a time bomb in your application.
  4. You lose any information about the thing you were trying to log.

By default this diagnostic has its severity set to Error but can be downgraded to Warning by adding the following to your editor.config:

# AA0008: Invalid log message template format.
dotnet_diagnostic.AA0008.severity = warning

Note that there is a built-in diagnostic (CA2023) for this in the upcoming NetAnalyzers release, at which point this package will be obsolete.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 130 2/13/2025