20 lines
1.3 KiB
Plaintext
20 lines
1.3 KiB
Plaintext
== Why is this an issue?
|
|
|
|
A log entry should contain all the relevant information about the current execution context. The https://learn.microsoft.com/en-us/dotnet/api/system.exception[Exception] raised in a catch block not only provides the message but also:
|
|
|
|
* the exception type
|
|
* the https://learn.microsoft.com/en-us/dotnet/api/system.exception.stacktrace[stack trace]
|
|
* any https://learn.microsoft.com/en-us/dotnet/api/system.exception.innerexception[inner exceptions]
|
|
* and more about the cause of the error.
|
|
|
|
https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loggerextensions[Logging methods] provide overloads that accept an `Exception` as a parameter and
|
|
https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-providers[logging providers] persist the `Exception` in a structured way to facilitate the tracking of system failures. Therefore `Exceptions` should be passed to the logger.
|
|
|
|
The rule covers the following logging frameworks:
|
|
|
|
* Nuget package - https://www.nuget.org/packages/Castle.Core[Castle.Core]
|
|
* Nuget package - https://www.nuget.org/packages/Common.Logging.Core[Common.Core]
|
|
* Nuget package - https://www.nuget.org/packages/log4net[log4net]
|
|
* Nuget package - https://www.nuget.org/packages/NLog[NLog]
|
|
* Nuget package - https://www.nuget.org/packages/Microsoft.Extensions.Logging[Microsoft.Extensions.Logging]
|