0
votes

I have a .NET Core API project (Core 2.2) like this

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

            ILoggerFactory loggerFactory = new LoggerFactory()
                .AddConsole()
                .AddDebug();
            ILogger logger = loggerFactory.CreateLogger<Program>();
            logger.LogInformation(
            "This is a test of the emergency broadcast system.");
       }

       public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
       }
    }
}

Can anyone inform me where can I find the logging output? In VS output tab I can see nothing.

In here

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1

it mentions something about console but I run the app from VS2017

1
If you run this in IIS or IISExpress, there will be no console. You can also start your application in a console window using the drop-down next to the green 'play' icon. The debug output is visible in the Visual Studio Output dialog, if you select Debug from the drop-down menu. - sarvasana
Use .AddTrace() if you want to see it in Visual Studio console. - Rosdi Kasim
Would have been nice if you would have marked my comment as the answer to your question. - sarvasana
@Kris , I see it as comment, not an answer, not sure how can I mark it as acceptable answer - user3417479

1 Answers

1
votes

In this configuration (AddConsole, AddDebug) if you run the application in console mode (instead of IIS Express), you can see the outputs in the Console.

To do that, click on the small arrow next to the run button, select your project name.