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.
Solution: Add logging to the sample app - ASP.NET Core Tutorial
From the course: ASP.NET Core: Health Checks and Logging
Solution: Add logging to the sample app
(upbeat music) - [Instructor] Since we've shut down the database anyway, let's start with logging the exception. So, I hit F5 to start this in debug mode. The API is launching, and so far so good, however, when I try out a call to the API, well, the code tries to connect to the database, but no avail, and after a while, well, basically we give up or that gives up because the timeout is reached and then we get the exception. So, we get the exception here in the constructor. So, we could try to log with the constructor. What we could also do is we could go to programs. Yes, and in the main method, just globally lock all exceptions. However, since I was specifically asking for the database and the database has only been used here, we can try something like this. So, we do a try and then catch an exception and make sure, that you're first set, logger, and then the database context. And then we could do a…
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
-
-
-
(Locked)
Understanding ILogger<T>1m 48s
-
(Locked)
What's in the template?6m 3s
-
(Locked)
Adding log entries5m 38s
-
(Locked)
Understanding log levels4m 48s
-
(Locked)
Configuring logging7m 40s
-
(Locked)
Logging to files7m 17s
-
(Locked)
Logging to Azure8m 12s
-
(Locked)
Using log scopes4m
-
(Locked)
Challenge: Add logging to the sample app1m 17s
-
(Locked)
Solution: Add logging to the sample app4m 26s
-
(Locked)
Summary of ASP.NET logging1m
-
(Locked)
-