From the course: ASP.NET Core: Health Checks and Logging

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

What's in the template?

What's in the template? - ASP.NET Core Tutorial

From the course: ASP.NET Core: Health Checks and Logging

Start my 1-month free trial

What's in the template?

- [Instructor] Let's have a look how we can use the ILogger interface in our ASP.NET Core application. First of all, of course, we need a project. If you set up a new project the template we want to use is ASP.NET Core web project, and then we can either use an ASP.NET Core web application or an API application because that's based on ASP.NET Core as well. We'll have a look at the code that is generated but basically in program.cs, we will have a call to create default builder, and what that does is it provides us with a couple of log providers, they're already there, we can use them right away. The only thing which is missing or basically which we need to know is how can we access those loggers? What we can do is in the constructor of say our Razor Page or of our controller, we can use dependency injection. So we just in the constructor, provide an argument of type ILogger, and then that is dependency injected into…

Contents