Q:

Logging in Application Insights for .NET Core 2.1 Console app with LoggerFactory

I have a .NET Core 2.1 Console application.  I have added all the Nuget packages needed. 
private static IConfiguration Configuration { get; set; }
static void Main(string[] args)
{
    ServiceCollection services = new ServiceCollection();
    ConfigureServices(services);
    var serviceProvider = services. BuildServiceProvider();
    var logger = serviceProvider. GetService<ILoggerFactory>()
        .CreateLogger<Program>()
    var service = serviceProvider. GetService<TestClass>();
    service. TimmerTriggerTask();
}

private static void ConfigureServices(IServiceCollection services)
{
    IConfiguration config = new ConfigurationBuilder()
            .AddJsonFile("appsettings.json", true, true)
            .Build();
    services. AddApplicationInsightsTelemetry("8028437c-1111-2222-8293-2cf3f3f106a8"); //instrumentation key
    services. AddLogging(builder => builder. AddConsole());
}

TestClass.cs
public class TestClass
{
    private readonly ILogger<TestClass> _logger;

    public TestClass(ILogger<TestClass> logger)
    {
        Console. WriteLine("Ctor");
        _logger = logger;
    }

    public void TimmerTriggerTask()
    {
        Console. WriteLine("Timer");
    //LOG BELOW IN APPLICATION INSIGHTS
        _logger. LogTrace("Hello World");
        _logger. LogInformation(DateTime. Now. ToString());
    }
}

I need to log all the information and exceptions in Application Insights.  looking to integrate loggerfactory with applicationInsights. 
I am looking for something what we can do in .NET Core Web app
WebHost. CreateDefaultBuilder(args).UseApplicationInsights()
loggerFactory. AddApplicationInsights(app. ApplicationServices, defaultLogLevel);

Please help me as how do i use logger classes to log into applicationinsights. 
Please provide an alternative solution if what i am doing is incorrect. 

A:

update:
For .net core 2.1 console app, you can use the following code:
using Microsoft. ApplicationInsights;
using Microsoft. Extensions. Configuration;
using Microsoft. Extensions. DependencyInjection;
using Microsoft. Extensions. Logging;
using System;

        static void Main(string[] args)
        {

            var telemetryClient = new TelemetryClient() { InstrumentationKey = "your instrumentation key" };

            ServiceCollection services = new ServiceCollection();
            services. AddSingleton(x => telemetryClient);

            var provider = services. BuildServiceProvider();

            var loggerFactory = new LoggerFactory();
            loggerFactory. AddApplicationInsights(provider, LogLevel. Information);

            var logger = loggerFactory. CreateLogger<Program>();
            logger. LogInformation("a test from 0911 again...");
            logger. LogError("a error test from 0911 again...");

            Console. WriteLine("aaa");

            telemetryClient. Flush();
            System. Threading. Thread. Sleep(5000);
        }

After running, in the visual studio output window, I can see the telemetry data are sent, screenshot as below:

And also, it was also shown in azure portal, screenshot as below:

