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 - ASP.NET Core Tutorial
From the course: ASP.NET Core: Health Checks and Logging
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Understanding ILogger<T>1m 48s
-
What's in the template?6m 3s
-
Adding log entries5m 38s
-
Understanding log levels4m 48s
-
Configuring logging7m 40s
-
Logging to files7m 17s
-
Logging to Azure8m 12s
-
Using log scopes4m
-
Challenge: Add logging to the sample app1m 17s
-
Solution: Add logging to the sample app4m 26s
-
Summary of ASP.NET logging1m
-
-