can't capture traces when instrumenting dotnet core 2 console app RRS feed

  • Question

  • I can see the information from TelemetryClient but I can`t those captured by ILogger.
    public class Program
    	static IConfiguration _configuration;
    	static void Main(string[] args)
    		var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
    		IConfigurationBuilder builder = new ConfigurationBuilder();
    		_configuration = Configure(builder, environmentName);
    		var instrumentationKey = _configuration["ApplicationInsights:InstrumentationKey"];
    		ILoggerFactory loggerFactory = new LoggerFactory();
    		var config = new JobHostConfiguration();
    		config.DashboardConnectionString = "xxxx";
    		config.LoggerFactory = loggerFactory
    			.AddApplicationInsights(instrumentationKey, null)
    		var host = new JobHost(config);
    	private static IConfiguration Configure(IConfigurationBuilder config, string environmentName)
    		return config
    			.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    			.AddJsonFile($"appsettings.{environmentName}.json", optional: true, reloadOnChange: true)
    public class Functions
    	public static async Task ProcessMethod(ILogger log)
    		TelemetryClient client = new TelemetryClient();
    		client.InstrumentationKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    		while (true)
    			// Do something.      
    			log.LogTrace($"ILogger.LogTrace - ILogger.LogTrace");
    			client.TrackTrace($"TrackTrace TelemetryClient - TrackTrace TelemetryClient");
    			Console.WriteLine("This ProcessMethod method is executed");			await Task.Delay(TimeSpan.FromMinutes(1));

    any tips?

    Thiago Custodio | Software Engineer
    Meu livro de Azure

    Friday, November 23, 2018 5:36 PM

All replies

  • Reading traces from ILogger in Console App is not currently supported. It is supported in regular Asp.Net Core apps only.

    The following is the issue tracking this: We are likely to move the Ilogger adaptor outside of the Core package, so as to enable using it with console apps. No ETA yet, but likely in the next 2-3 months.

    Tuesday, November 27, 2018 1:45 AM