exceptionless / Exceptionless.Net

Exceptionless clients for the .NET platform
https://exceptionless.com
Other
554 stars 142 forks source link

Using Exceptionless.NLog with Exceptionless.AspNetCore can not capture the HTTP context information #262

Closed h82258652 closed 2 years ago

h82258652 commented 2 years ago

I found if I set serverUrl or apiKey in NLog.config, the Exceptionless can not capture the HTTP context information (such as HTTP method).

I clone the source code and found the problem. Snipaste_2021-11-01_16-42-46

If we set serverUrl or apiKey, in line 27, it will create a new ExceptionlessClient.

Snipaste_2021-11-01_16-43-28

In UseExceptionless method, if we do not pass the client, it will get from the services or use the default client. And then register some plugins about asp.net core to log the HTTP context information. But in the first step, it creates a new client and we can't pass it to the second step.

niemyjski commented 2 years ago

This is by design, if you want to share additional integrations, plugins and configuration, don't set the server url or api key in the NLog config. We did this so you could specify a lightweight performant client instance just for logging but not something we actively recommend for most instances. If you need any help configuring the client, please let us know.