Skip to content

Generic Interface Type with ILogger Interface is own class #187

Answered by christiannagel
ShervanN asked this question in Q&A
Discussion options

You must be logged in to vote

Using the ILogger interface, you cannot inject the non-generic version of this interface. You'll get an error with this. The ILogger interface needs a name to use this for logging - this way you can find where log messages relate to. With this, you can either inject ILoggerFactory, and pass a name using the CreateLogger method - or inject the ILogger interface with a generic parameter using a class. The ILogger implementation than uses the name of the class as a category name for logging - e.g. in the code snippet the name "QuotesServer".

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ShervanN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants