ASP.Net Core 2.0 and logging

I created a new project for ASP.Net Core 2.0. Added this code to 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 the framework, but I can't see anything. Although, if I create an ASP.Net Core 1.1 web project, the logged lines are already in Program.cs

and I can 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?

+3


source to share


1 answer


Ok, now I'm a little stupid, but to achieve what I wanted, I had to change LogLevel

of Debug

and Console

in appsettings.json to something less thanWarning



+5


source







All Articles