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

Unlock the full course today

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

Using log scopes

Using log scopes - ASP.NET Core Tutorial

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

Start my 1-month free trial

Using log scopes

- [Narrator] The last asp.net core logging feature I would like to show you is how to use scopes. If you have several log entries that belong together you can put them within a scope. And that's how it looks like you have the begin scope method which implements I disposable. So we can use the using statement. And then as the parameter, you just provide a string. You can also use a string of placeholders just like when you do regular log entries and then all the log entries created within that scope also receive the scope information in the entry. So when you have a look at log entries later it's easier to identify to context for some of those log entries. If you put them in an aptly named scope in order to see those scopes you have to add some additional configuration. If you are logging to the console window, as we did most of the course you can just create settings for that console window. And the setting we need is…

Contents