Blazor Server Application Global Error Handling

Cenk 951 Reputation points


I am working on a Blazor Server Application, I want to log errors into the database table and I wonder if there is a single/global catch? Can you please guide me?

Thank you.

A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,372 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Willem Boeré 1 Reputation point


    I Would use the standard .NET ILogger.
    injecting ILogger in your components and configuring it at application startup, you can centrally manage logging via configuration in an easy way.

    You're talking about logging the errors in a database table, which is fine, but think where to log the errors in case the logging dataabase isn't there.
    Maybe make a difference between system errors (like logging database unavailable) and application errors (that are being logged in your database).

    This article describes nicely how to implement logging:

    and this article describes how to apply this in Blazor:

    Have fun,



    0 comments No comments