SAHB.GraphQLClient icon indicating copy to clipboard operation
SAHB.GraphQLClient copied to clipboard

Accessing the log messages

Open chelliwell opened this issue 5 years ago • 1 comments

I see that some of the classes make use of LoggerFactory, and that an example app has a section "Using dependency injection and console logging". Is it possible to use the latter without the former? If so, could you maybe add a doc section about a basic method/example to grab these messages in the 'client' code?

chelliwell avatar Oct 29 '19 13:10 chelliwell

The LoggerFactory interface is from Microsoft.Extensions.Logging which is for example used with ASP.net Core. The loggerfactory interface is injected using property injection like this:

new GraphQLFieldBuilder() { LoggerFactory = provider.GetService<ILoggerFactory>() }

The code is from here: https://github.com/sahb1239/SAHB.GraphQLClient/blob/develop/src/SAHB.GraphQLClient/GraphQLClientBuilder.cs#L28

Some examples of using loggerfactory can be found here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.0

sahb1239 avatar Nov 11 '19 19:11 sahb1239