Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Blazor Server #141

Open
sebastianbk opened this issue Mar 8, 2022 · 3 comments
Open

Support for Blazor Server #141

sebastianbk opened this issue Mar 8, 2022 · 3 comments

Comments

@sebastianbk
Copy link

Thanks a lot for all of the work that has gone into this fantastic project. I've used it for multiple ASP.NET Core MVC projects and it works so well. I really appreciate all of your efforts!

Now, I'm building a Blazor Server app and, unfortunately, ElmahCore does not catch exceptions thrown in Blazor Server components. Is there any way this could be added easily?

@sebastianbk
Copy link
Author

I'm actually a little puzzled why this doesn't work. Blazor Server logs exceptions to Microsoft.Extensions.Logging but, even though I have configured ElmahCore using ConfigureLogging, I don't see any exceptions raised in components.

builder.Host.ConfigureLogging((context, logging) =>
{
    logging.Services.AddElmah<PgsqlErrorLog>(options =>
    {
        options.ConnectionString = npgsqlConnectionStringBuilder.ConnectionString;
        options.OnPermissionCheck = (context) =>
        {
            var email = context.User?.Claims?.Where(c => c.Type.Equals(System.Security.Claims.ClaimTypes.Email))
                .Select(c => c.Value)
                .FirstOrDefault();
            return email.EndsWith("@*******.***");
        };
    });
});

Am I doing something wrong?

ElmahCore pushed a commit that referenced this issue May 14, 2022
@ElmahCore ElmahCore reopened this May 14, 2022
@LukasKubicek
Copy link

Hi, has this been resolved? I have Blazor Server, added ElmahCore and it is logging things like 404 but not exceptions happening in Blazor Server - I mean exceptions that the default Microsoft logger stores in Windows Event log. I would like these exceptions to be saved into ElmahCore as well.

@justBanks
Copy link

This issue is now solved using .NET's ErrorBoundary component together with the ElmahExtensions.RaiseError(exception) statement. In fact, when implementing global error handling, I find that Elmah logs errors in Blazor server as well as in client components.

🔥See this comment here, which references the article here 🔥🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants