title: ASP.NET Core 2.1 Web.API change application insights instrumentation key for logging
body: <p>I would like to enable logging to app insights from WebApi (with custom logger).
  Everything works well, but I need to provide <code>instrumentation key</code> in <code>appsetting.json</code> with forced convention:</p>
  
  <pre><code>"Values": {
     "AppInsightsKey":  "I want to put key here" 
  },
  "ApplicationInsights": {
     "InstrumentationKey": "Now I must put key here"
  }
  </code></pre>
  
  <p>However I can't override this second setting directly from Azure Settings:
  <a href="https://i.stack.imgur.com/EFTiJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFTiJ.png" alt="enter image description here"></a></p>
  
  <p>Is there any way to set up it properly? </p>
  
  <p>Actually in my <code>Startup.cs</code> I am configuring logger:</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace);
  }
  </code></pre>
  
  <p>My logger wrapper:</p>
  
  <pre><code>using Microsoft.Extensions.Logging;
  ...
  public class MyCustomLogger : IMyCustomLogger
  {
      private readonly ILogger _logger;
  
      public MyCustomLogger(ILogger&lt;MyCustomLogger&gt; logger)
      {
          _logger = logger;
      }
      public void LogInformation(string message, params object[] args)
      {
          _logger.LogInformation(message, args);
      }
  }
  </code></pre>
  
  <p>PS. If I can override <code>ApplicationInsights.InstrumentationKey</code> on Azure, this will be the proper solution as well. </p>