title: Moving NLog to it's Own Logger Service Project and Keep Current Logger Syntax
body: <p>I have a .Net 6 Web API project with NLog configured following the steps at <a href="https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-6" rel="nofollow noreferrer">Getting started with ASP.NET Core 6</a>. I'd like to move NLog references to it's own Class Library. I was following an article on <a href="https://code-maze.com/net-core-web-development-part3/" rel="nofollow noreferrer">ASP.NET Core Web API – Logging With NLog</a>. The problem is that this method requires me to change all my controllers from</p>
  <pre><code>private readonly ILogger&lt;MyController&gt; _logger;
  public MyController(ILogger&lt;MyController&gt; logger) {...}
  </code></pre>
  <p>to</p>
  <pre><code>private readonly ILoggerManager _logger;
  public MyController(ILoggerManager logger) {...}
  </code></pre>
  <p>Is there a way to get NLog in it's own Class Library, yet keep the current syntax that was built-in to the API?</p>
  <p>Here's my current <code>program.cs</code> file:</p>
  <pre><code>using NLog;
  
  var logger = LogManager
              .LoadConfiguration(string.Concat(Directory.GetCurrentDirectory(), &quot;/Configs/NLog/nlog.config&quot;))
              .Setup()
              .SetupExtensions(x =&gt; x.RegisterLayoutRenderer&lt;BuildConfigLayoutRenderer&gt;(&quot;BuildConfiguration&quot;))
              .GetCurrentClassLogger();
  logger.Debug(&quot;init main&quot;);
  
  try {
      var builder = WebApplication.CreateBuilder(args);
  
      // Add services to the container.
  
      // NLog: Setup NLog for Dependency injection
  
      /********************************************
      the 2 lines below are:
          1) the default taken from NLog docs and
          2) the code from the article I was following (currently disabled)
      ********************************************/
  
      builder.Host.UseNLog(); // 1
      //builder.ConfigureLoggerService(); // 2
  
      /********************************************/
  
      builder.Services.AddControllers();
      // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
      builder.Services.AddEndpointsApiExplorer();
      builder.Services.AddSwaggerGen();
  
      var app = builder.Build();
  
      // Configure the HTTP request pipeline.
      if (app.Environment.IsDevelopment()) {
          app.UseSwagger();
          app.UseSwaggerUI();
      }
  
      app.UseHttpsRedirection();
  
      app.UseAuthorization();
  
      app.MapControllers();
  
      app.Run();
  } catch (Exception exception) {
      logger.Error(exception, &quot;Stopped program because of exception&quot;);
      throw;
  } finally {
      LogManager.Shutdown();
  }
  </code></pre>