Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Asp.Net core MVC 2.0 logging

$
0
0

Hello,

Here is what i've done: I have injected an ILogger in my Controller's constructor:

public MyController(ILogger<HomeController> logger)
{
_logger = logger;
}

public IActionResult Index()
{
_logger.LogError("Here is a log message");
return View();
}

And Here is what i've changed in Program.cs:

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConsole();
logging.AddDebug();
})
.UseStartup<Startup>()
.Build();
}

The application is hosted on a Windows Server computer with IIS.
The application works fine but i cannot find where the log is written...

Thanks


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>