CA1848: Use the LoggerMessage delegates
| Value | |
|---|---|
| Rule ID | CA1848 |
| Category | Performance |
| Fix is breaking or non-breaking | Non-breaking |
Cause
Use of logger extension methods, such as LogInformation and LogDebug.
Rule description
For high-performance logging scenarios, use the LoggerMessage pattern.
How to fix violations
Use LoggerMessage to fix violations of this rule.
LoggerMessage provides the following performance advantages over Logger extension methods:
- Logger extension methods require "boxing" (converting) value types, such as
int, intoobject. The LoggerMessage pattern avoids boxing by using static Action fields and extension methods with strongly typed parameters. - Logger extension methods must parse the message template (named format string) every time a log message is written. LoggerMessage only requires parsing a template once when the message is defined.
When to suppress warnings
Do not suppress a warning from this rule.
See also
Povratne informacije
Pošalјite i prikažite povratne informacije za