title: ILogger logs to app insights locally but not on azure
body: <p>The following code work on my machine locally. That means all log statements are in app insights after some minutes...</p>
  <p>When I deploy the application with Publish as Webjob all gets deployed BUT there are no log statement of the triggered webjob although I can see it runs every 5 seconds...</p>
  <p>I also tried Thread.Sleep(30000); // 30 seconds...</p>
  <p>Why does app insights work locally but not hosted on azure?</p>
  <p>Console application .NET 4.7.2:</p>
  <pre><code>  // Create the DI container.
                  IServiceCollection services = new ServiceCollection();
      
                  var appInsightsKey = ConfigurationManager.AppSettings.Get(&quot;APPINSIGHTS_INSTRUMENTATIONKEY&quot;);
                  Console.WriteLine($&quot;appInsightsKey: {appInsightsKey}&quot;);
      
                  // Being a regular console app, there is no appsettings.json or configuration providers enabled by default.
                  // Hence instrumentation key and any changes to default logging level must be specified here.
                  services.AddLogging(loggingBuilder =&gt;
                  {
                      loggingBuilder.AddFilter&lt;ApplicationInsightsLoggerProvider&gt;(&quot;&quot;, LogLevel.Information);
                      loggingBuilder.AddApplicationInsights(appInsightsKey);
                  }
                  );
      
                  services.AddApplicationInsightsTelemetryWorkerService(appInsightsKey);
                  IServiceProvider serviceProvider = services.BuildServiceProvider();
                  // Obtain logger instance from DI.
                  ILogger&lt;Program&gt; logger = serviceProvider.GetRequiredService&lt;ILogger&lt;Program&gt;&gt;();
      
                  logger.LogWarning(&quot;nogger 2: warning&quot;);
                  logger.LogInformation(&quot;nogger2: information&quot;);
                  logger.LogError(&quot;nogger2: error&quot;);
      
                  Console.WriteLine(&quot;This is the end...&quot;);
      
                  Task.Delay(5000).Wait();
  </code></pre>
  <p><strong>UPDATE</strong></p>
  <p>I am using Microsoft.ApplicationInsights.WorkerService nuget:</p>
  <p><a href="https://docs.microsoft.com/de-de/azure/azure-monitor/app/worker-service" rel="nofollow noreferrer">https://docs.microsoft.com/de-de/azure/azure-monitor/app/worker-service</a></p>
  <p>scroll down for .NET framework console apps!</p>
  <p>I have noticed something interesting (the different display of the references...) but maybe it does not make any difference in the end because with both projects the <strong>ILogging</strong> in azure does not work:</p>
  <p><strong>4.7.2</strong> project:</p>
  <p><a href="https://i.stack.imgur.com/NznMc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NznMc.png" alt="xx" /></a></p>
  <p><strong>4.6.1</strong> project:</p>
  <p><a href="https://i.stack.imgur.com/kDjSe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kDjSe.png" alt="enter image description here" /></a></p>
  <p>I have also just deployed as Azure Webjob vom Visual Studio with debug mode and still it does not work and I even configured appinsights extra in that deploy dialog but no difference!</p>