Giter Site home page Giter Site logo

500 errors not logging about classic HOT 11 OPEN

serilog-web avatar serilog-web commented on May 28, 2024
500 errors not logging

from classic.

Comments (11)

nblumhardt avatar nblumhardt commented on May 28, 2024

Thanks for the report. I haven't encountered this, may need some investigation. Help welcome, if you're able to build from source and take a look.

Which Serilog version are you running, and to which sink(s)? Thanks!

from classic.

drjaydenm avatar drjaydenm commented on May 28, 2024

I am using the Seq sink. I was using outdated versions of these packages. I have now updated them and am using Serilog 2.2.1 and Serilog.Sinks.Seq 3.0.1. The 500 errors are now coming through on Seq but have no exception data and are only logging as Information level, which is not very helpful as it has no context of the error (stack trace/line numbers etc).

from classic.

nblumhardt avatar nblumhardt commented on May 28, 2024

Sounds like progress! Glad to hear you have some data captured now.

Can you please send an example of one of the events received at Seq? Particularly the message associated with the event - redacted if necessary of course. Any information about associated properties on the event would also help to debug this on this end. Thanks!

from classic.

drjaydenm avatar drjaydenm commented on May 28, 2024

Here's an example of a log message we are seeing in Seq

serilog500message

from classic.

nblumhardt avatar nblumhardt commented on May 28, 2024

Thanks for the info. I think what's probably happening here (at a guess) is that another handler/exception filter is handling the exception. Are there any other error-handling paths that might prevent the exception from bubbling up?

I've just merged #31 to switch the level to Error appropriately in this scenario, if you have a chance to grab the 2.0.10 build and check it out.

from classic.

drjaydenm avatar drjaydenm commented on May 28, 2024

Thanks for the speedy fix for that, seems to be logging with Error level now for 500 server errors, even with no exception data.

Regarding capturing exception data, I am using the setup in web.config. I have worked out just now that exception info is captured for local requests but not remote ones. Any ideas what may be causing this? I though maybe there was a in the web.config, but it's not in there.

from classic.

drjaydenm avatar drjaydenm commented on May 28, 2024

I have found a solution. Adding customErrors Off like the below works. I have errors handled using IIS httpErrors still so it isn't showing the user any exception details. I tried setting customErrors to On and there is no exception info locally or remotely, DetailedLocal shows the original problem of exceptions locally and not remotely and Off shows exceptions for both.

I guess the solution is to make sure customErrors is set to Off!

<customErrors mode="Off"></customErrors>

from classic.

nblumhardt avatar nblumhardt commented on May 28, 2024

Thanks for the update. Looking into it further, it seems like generic error handling and customErrors are often at odds. I think we should keep this ticket open to collect more data, but I am glad to hear you found a resolution.

from classic.

v1ct0rv avatar v1ct0rv commented on May 28, 2024

Hi @drjaydenm I have same issue I had to turn off custom errors in web.config:
<customErrors mode="Off"></customErrors>

But the IIS error pages are not working for me, could you plase share your web.config?

from classic.

drjaydenm avatar drjaydenm commented on May 28, 2024

I had to use httpErrors over custom errors for it to work correctly. The httpErrors work more at the IIS level than at the ASP level. You can read more about it here https://www.iis.net/configreference/system.webserver/httperrors

from classic.

tsimbalar avatar tsimbalar commented on May 28, 2024

I don't know if this will help, but in my case (MVC 5 app), the same app behvaes pretty differently depending on the settings .

  • On my local machine with those settings :
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <customErrors mode="Off">
      <error statusCode="400" redirect="Error/Error400" />
      <error statusCode="401" redirect="Error/Error401" />
      <error statusCode="403" redirect="Error/Error403" />
      <error statusCode="404" redirect="Error/Error404" />
      <error statusCode="500" redirect="Error/Error500" />
    </customErrors>
  </system.web>

I do get the full exception details
image

  • and on a more "prod-ish" environment with those settings (note the customErrors mode = "On") :
  <system.web>
    <compilation debug="false" targetFramework="4.6.1" />
    <customErrors mode="On">
      <error statusCode="400" redirect="Error/Error400" />
      <error statusCode="401" redirect="Error/Error401" />
      <error statusCode="403" redirect="Error/Error403" />
      <error statusCode="404" redirect="Error/Error404" />
      <error statusCode="500" redirect="Error/Error500" />
    </customErrors>

I don't have the exception details:
image

In order to fix this, I had to remove the HandleErrorAttribute that was applied globally.

    public class FilterConfig
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            //filters.Add(new HandleErrorAttribute{ View = "Error500", Order = 1 });
        }
    }

Without this handler, the app seems to behave the same way no matter the options.

from classic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.