title: Logs not getting written to ApplicationInsights
body: <p>Here is my .net 6 program.cs basic code. In the Following sample code I am trying to write basic logs into Application insights.
  I have Nuget package reference in my project file</p>
  <pre><code>&lt;PackageReference Include=&quot;Microsoft.ApplicationInsights.AspNetCore&quot; Version=&quot;2.21.0&quot; /&gt;
      &lt;PackageReference Include=&quot;Microsoft.ApplicationInsights.DependencyCollector&quot; Version=&quot;2.21.0&quot; /&gt;
  </code></pre>
  <p>I am using classic application insights</p>
  <pre><code>using Microsoft.ApplicationInsights.Extensibility;
  using Microsoft.ApplicationInsights;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Hosting;
  using Microsoft.Extensions.Logging.ApplicationInsights;
  using Microsoft.ApplicationInsights.AspNetCore.Extensions;
  
  var builder = WebApplication.CreateBuilder(args);
  
  builder.Services.AddControllersWithViews();
  
  builder.Services?.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions
  {
      ConnectionString = &quot;InstrumentationKey=19233009-a529-494c-9b4b-3fd57d363357;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/;LiveEndpoint=https://centralus.livediagnostics.monitor.azure.com/&quot;
  
  }); 
  var app = builder.Build();
  
  // Configure the HTTP request pipeline.
  if (!app.Environment.IsDevelopment())
  {
      app.UseExceptionHandler(&quot;/Home/Error&quot;);
      // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
      app.UseHsts();
  }
  
  app.UseHttpsRedirection();
  app.UseStaticFiles();
  
  app.UseRouting();
  app.UseAuthorization();
  app.Logger.LogInformation(&quot;TEST LOGS&quot;);
  
  
  app.MapControllerRoute(
      name: &quot;default&quot;,
      pattern: &quot;{controller=Home}/{action=Index}/{id?}&quot;);
  
  app.Run();
  </code></pre>
  <p>Any suggestions why is it not logging &quot;Test logs&quot; into my application insights logs</p>
  <p>Update</p>
  <p>As suggested by @jasonc. I followed the instructions from example <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#example-programcs" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#example-programcs</a>, and now my logs are getting written from program.cs file to my application insights. But still not logging Ilogger logs from my controller.</p>
  <p>I have the following code in my controller, but it is not getting written to application insights.</p>
  <pre><code>  public class MyController : Controller
      {
          private readonly ILogger&lt;MyController&gt; _logger;
         
  
          public MyController(ILogger&lt;MyController&gt; logger)
          {
              _logger = logger;
             
          }
  
         
          public IActionResult Index()
          {
             
             _logger.LogInformation(&quot;From myController, running Index.&quot;);
           }
  
     }
  </code></pre>