问题
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?
P.S. It's a bit strange that the documentation still contains these images that you cannot even see.
回答1:
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!");
来源:https://stackoverflow.com/questions/40148660/how-to-get-a-console-output-in-asp-net-core-with-iis-express