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

UseNLog() in 4.5.0-beta01 removes ConsoleLogger from .Net Core #199

Closed
agentschmitt opened this issue Oct 13, 2017 · 5 comments · Fixed by #205
Closed

UseNLog() in 4.5.0-beta01 removes ConsoleLogger from .Net Core #199

agentschmitt opened this issue Oct 13, 2017 · 5 comments · Fixed by #205

Comments

@agentschmitt
Copy link

After updating from NLog.Web.AspNetCore 4.3.1 to 4.5.0-beta01, the ConsoleLogger from .NET does no longer work.
"CreateDefaultBuilder" adds the ConsoleLogger by default, but after i am adding "UseNlog" no messages are logged to console any more.
Does Nlog Registration remove the Loggers already registered?
Maybe this issue is related? "Add option to remove other loggers #192"

This is my Nlog Setup, created as descriped in https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2

            var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();

            var hostBuilder = WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseNLog();
@304NotModified
Copy link
Member

Have you check this. We don't remove any logger. Probably the issue is the custom log factory

@304NotModified
Copy link
Member

Thanks again for reporting!

@snakefoot
Copy link
Contributor

When using GetCurrentClassLogger() then one is no longer using Microsoft Extension Logging, but writing directly to the NLog-engine, maybe this is the confusing part?

@304NotModified
Copy link
Member

304NotModified commented Oct 13, 2017

I found the issue (but not yet how to solve)

in asp.net 2 we register NLogLoggerFactory, instead of NLogLoggerProvider. - this will replaces Microsoft's loggerFactory.

This is a more clean way, but the side-effect is that addConsole is not working and that loggers that were register on (Microsoft's) loggerFactory are gone.

304NotModified added a commit to 304NotModified/NLog.Web that referenced this issue Oct 13, 2017
So config made before UseNLog is still applied and Microsoft's addConsole is also working

fixes NLog#199
@304NotModified
Copy link
Member

fixed in beta 2

kvpro929 added a commit to kvpro929/NLog.Web that referenced this issue Oct 30, 2022
So config made before UseNLog is still applied and Microsoft's addConsole is also working

fixes NLog/NLog.Web#199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants