NickCraver / StackExchange.Exceptional

Error handler used for the Stack Exchange network
https://nickcraver.com/StackExchange.Exceptional/
Apache License 2.0
860 stars 170 forks source link

NuGet package Not working with Asp.net core #114

Closed AhmedRagheb closed 6 years ago

AhmedRagheb commented 6 years ago

I've installed the NuGet package in my DotNetCore 2.0 project and setup the SQL store and nothing logged in Db Install-Package StackExchange.Exceptional.AspNetCore -Version 2.0.0-alpha2-00171

I've downloaded the DotNetCore Sample and remove project reference and replaced with NuGet package and also nothing logged in Db.

NickCraver commented 6 years ago

@AhmedRagheb Did you setup the DB by creating the schema? Instructions here: https://nickcraver.com/StackExchange.Exceptional/Providers/SqlServer

If you have the route added to see the error log (as in the sample application), you can see why it's not logging.

AhmedRagheb commented 6 years ago

@NickCraver Thanks for your reply. Yes, I did. If I download your sample project, everything will work fine. but if I remove the reference project and replace it with the NuGet package, it will not log. So, the issue not in DB setup, the problem in NuGet package (I think).

zbecknell commented 6 years ago

I'm reproducing this using the latest MyGet package (alpha3-00183). I just added it and am setting up Exceptional like so:

In ConfigureServices:

services.AddExceptional(settings =>
{
    settings.SetDefaultStore(new SQLErrorStore(new ErrorStoreSettings
    {
        ApplicationName = "App Name",
        Type = "SQL",
        ConnectionString = Configuration.GetConnectionString("DefaultConnection")
    }));
});

In Configure:

app.UseExceptional();

I do have the table created. Trying to get to the bottom of it now.

zbecknell commented 6 years ago

Ok, I found my problem. My request pipeline was ordered incorrectly. I had this:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseExceptional();

    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
        app.UseBrowserLink();
        app.UseDatabaseErrorPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
    }

And the DeveloperExceptionPage was terminating the pipeline before the exception reached Exceptional to log. Moving app.UseExceptional() after the DeveloperExceptionPage enabled the logging.

Edit:

Of course I realize now that my situation is just user error vs what @AhmedRagheb is facing.

NickCraver commented 6 years ago

@AhmedRagheb The problem was (I'm fairly sure) NuGet just didn't have a recent build. If you try latest from NuGet it should work fine :)