TState
in ILogger interface
#114627
Unanswered
alexandrehtrb
asked this question in
General
Replies: 1 comment 1 reply
-
The |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am writing a custom Logger for a project and I noticed that the ILogger interface could be more straight-forward and easier to understand.
The
TState
generic type in the ILogger interface is vague, but in practice, it is almost (?) always an instance of the FormattedLogValues class.runtime/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/ILogger.cs
Line 23 in 4daefae
In
LoggerExtensions.cs
:runtime/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LoggerExtensions.cs
Line 486 in 4daefae
ASP.NET Core logs have similar classes.
Changing the ILogger interface TState generic to concrete FormattedLogValues would make the interface clearer to understand and eliminate type checking and casting (performance benefit). In the case of ASP.NET Core, maybe it could use a derived class inheriting from FormattedLogValues.
Related issues: #90226 and #67577
Beta Was this translation helpful? Give feedback.
All reactions