0
votes

I'm developing a .NET Core 3.0 web application and publishing it as an Azure App Service.

In one of the controller methods, I do this:

System.Diagnostics.Trace.TraceError("If you're seeing this, something wonderful happened");

Then I go in the Azure App Service - App Service Logs and enable "Application Logging". Next, I go in "Log stream", where I'm supposed to be able to see live debug logging, but I don't see anything.

Please advice!

...

Edited: I changed my Program.cs file a bit but it still doesn't work. Here's my Program.cs file:

    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureLogging(logging =>
                {
                    logging.ClearProviders();
                    logging.AddConsole();
                })
                .UseStartup<Startup>();
    }
2

2 Answers

1
votes

You need to change your logging to something like explained here. AFAIK System.Diagnostics.Trace is not really supported in ASP.NET Core.

0
votes

This seemed to work:

            WebHost.CreateDefaultBuilder(args)
                .ConfigureLogging(logging =>
                {
                    //logging.ClearProviders();
                    //logging.AddConsole();
                    logging.AddApplicationInsights("Application insights Instrumentation Key");
                })
                .UseStartup<Startup>();