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

Unlock the full course today

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

Adding log entries

Adding log entries - ASP.NET Core Tutorial

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

Start my 1-month free trial

Adding log entries

- [Narrator] It is now time for us to create our first block entries. Let's start with the web application we have and there let's have a look at our index cshtml razor page and the associated class index.cshtml.cs and in there, you see that we already have the boiler plate code that Visual Studio gave us. So we already have _logger and we can use that for instance, in the OnGet methods. So when there's a get request for this page we could just do a _logger. and then we have a couple of methods, the log method which you already saw on the slide at the interface but also something like LogCritical or LogError or LogInformation. And that has to do with different so-called "Log levels". You just use LogInformation, so far and have a look at log levels a little bit later. And then if you have a look at that, you see for overloads and let's just start with the most simple version. We just provide a log message and the log…

Contents