Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net Core 2.0 and logging

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?

like image 894
hasrthur Avatar asked Mar 08 '23 15:03

hasrthur


1 Answers

Ok, I feel a bit stupid now, but to achieve what I wanted I had to change LogLevel of Debug and Console in appsettings.json to something lower that Warning

like image 140
hasrthur Avatar answered Mar 19 '23 10:03

hasrthur