简体   繁体   中英

How to get a Console output in ASP.NET Core with IIS Express

ASP.Net Core documentation here has a nice console logging output like in the picture below with colors for various LogLevels. I have now created an application in Visual Studio and I see that it now runs behind IIS Express and I don't see the console anymore. I remember when I did run beta, then it did pop up Kestrel directly with this nice Console output.

Is it possible to get this nice window now?

PS It's a bit strange that the documentation still contains these images that you cannot even see.

在此处输入图片说明

In addition to Dawid Rutkowski's answer , on the top dropdown, don't select IISExpress, select the application name. You should be able to see the console and the web page.

Yes, it's possible with IIS Express. Use Microsoft.Extensions.Logging.Debug nuget package: https://github.com/aspnet/Logging/tree/master/src/Microsoft.Extensions.Logging.Debug . Configure logger in the Startup.cs:

loggerFactory.MinimumLevel = LogLevel.Debug;
loggerFactory.AddDebug( LogLevel.Debug );
var logger = loggerFactory.CreateLogger("Startup");
logger.LogWarning("Logger configured!");

And:

Console.WriteLine("Hi!");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM