Summary

In this chapter, we covered some of the tools and techniques that you can use to make it easier for you and the users of your API, who are developers themselves, to find and diagnose errors in your application.

Logging is one of the most helpful things you have in case of a problem. Often, it is the only way for you to find out what happened when the error occurred. The new logging framework that ASP.NET Core introduced is integrated very nicely with the ASP.NET Core request pipeline, and using it in your application code is straightforward. There are many logging providers that you can use, and I've shown you how you can use Application Insights, which provides a nice search window inside Visual Studio, along with other diagnostic utilities that can be used when running in production.

Because the users of your API are developers themselves, you need to make sure that they can consume the errors from your application and deal with them gracefully. I've shown you how to add a global exception filter so that error responses can be standardized in your application. Finally, you've learned what the OpenAPI specifications are, and how to automatically generate the Swagger file and Swagger UI in your application, so that developers can later use it to experiment with the API and generate client code from it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.55.20