Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No built-in support integration with Microsoft.Extensions.Logging #46

Open
timbussmann opened this issue Mar 23, 2020 · 0 comments
Open

No built-in support integration with Microsoft.Extensions.Logging #46

timbussmann opened this issue Mar 23, 2020 · 0 comments

Comments

@timbussmann
Copy link
Member

@timbussmann timbussmann commented Mar 23, 2020

The generic host uses Microsoft.Extensions.Logging as the built-in logging abstraction. The logger is managed by the generic host and configurable via hostBuilder.ConfigureLogging(...).

NServiceBus doesn't use the configured logger for it's logging output, as it continues to rely on the LogManager defined in NServiceBus. The LogManager needs to be configured before using any other NServiceBus API since the static caching of loggers (via static ILog logger = LogManager.GetLogger<T>()) will cache the logger the first time it is resolved. Many NServiceBus internal classes resolve the logger as part of the endpoint configuration & startup procedure which begins as part of calling UseNServiceBus (as it calls EndpointWithExternallyManagedContainer.Create internally). This means the logger is resolved before the logger managed by the generic host is available (as it is only available once the IServiceProvider has been built). Therefore, these two loggers are hard to integrate out-of-the-box.

A workaround also shown by our generic host sample is to use a community package written by Simon Cropp which is available here: https://www.nuget.org/packages/NServiceBus.MicrosoftLogging.Hosting/ (see the GitHub readme for usage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.