I generated a new project for ASP.Net Core 2.0. Added this code in Program.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); ... Then I go to the folder containing the project and run dotnet run:
Hosting environment: Development Content root path: C:\Users\arthur\Source\Repos\WebApplication5\WebApplication5 Now listening on: http://localhost:3000 Application started. Press Ctrl+C to shut down While navigating the site I want to see the logs generated by framework but I see nothing. Though if I generate ASP.Net Core 1.1 web project the lines with logging are already in Program.cs and I see the logs:
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 GET http://localhost:53680/ info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Executing action method WebApplication3.Controllers.HomeController.Index (WebApplication3) with arguments ((null)) - ModelState is Valid What am I missing?
.AddDebug();to program.cs if you want core to log the changes, but you need to use logLogWarning``LogInformationto log things you want. learn.microsoft.com/en-us/aspnet/core/fundamentals/loggingAddDebug()just adds logging to debug console of visual studio, withLog[Level]you just log what you want to log and I am interested in logs produced by ASP.Net itself, like ` Executing action method WebApplication3.Controllers.HomeController.Index (WebApplication3) with arguments ((null)) - ModelState is Valid`