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

Add AddNLogWeb with NLog LogFactory and NLogAspNetCoreOptions for better isolation #626

Merged
merged 1 commit into from
Jan 16, 2021

Conversation

snakefoot
Copy link
Contributor

@snakefoot snakefoot commented Jan 8, 2021

Allows one to do this:

        var logFactory = new NLog.LogFactory.Setup()
           .SetupExtensions(e => e.AutoLoadAssemblies(false))
           .RegisterNLogWeb()
           .LoadConfigurationFromFile("nlog.config", optional: false)
           .LoadConfiguration(builder => builder.LogFactory.AutoShutdown = false).LogFactory;

            builder.UseStartup<Startup>()
                    .ConfigureLogging((ctx, logging) =>
                    {
                        logging.ClearProviders();
                        logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Debug);
                        logging.AddNLogWeb(logFactory, new NLogAspNetCoreOptions() { ShutdownOnDispose = true });
                    });

So the MEL receives an isolated LogFactory, that is fully initialised (Instead of using the global NLog.LogManager).

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASP.NET Core ASP.NET Core - all versions enhancement size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants