The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Azure App Service - Web Apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
.net core and exception logging RRS feed

  • Question

  • I haven't been able to find any good guidance on how to see details about unhandled exceptions in azure from an mvc6 app.  I see failed requests in the requests & errors monitoring chart, but they never show up in the application events page or any logs.  

    I have application logging (blob) turned on, level: error, web server logging: file system, detailed error messages: on, failed request tracing: on.

    In Configure:

    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    
    if (env.IsDevelopment())
    {
       app.UseDeveloperExceptionPage();
       app.UseBrowserLink();
    }
    else
    {
       app.UseExceptionHandler("/Error");
    }

    In my error controller, I don't think this is necessary but I have it anyway:

            [Route("/error")]
            public IActionResult Index(){
                var exceptionHandlerFeature = HttpContext.Features.Get<IExceptionHandlerFeature>();
                var exception = exceptionHandlerFeature.Error;
                _logger.LogError(666,exception,"Unhandled Exception");
                return View();
            }

    Not sure what else I am missing.

    Wednesday, October 19, 2016 9:49 PM

All replies

  • Hi,

    Thank you for posting on the azure forums!

    Just to confirm have you checked the logs using KUDU console? If not please check once.

    you can check the logs browsing through the Kudu console by accessing the url: https://****.scm.azurewebsites.net/ (enter your website name instead of ****) You should be able to find the log files under the debug console.

    Please check if there are any error logs. Refer to the link for more information on this.

    Try giving the below line of code in your else block and check if that makes any difference.

                 app.UseExceptionHandler("/Home/Error");

    Please check the blog post Error Handling and SO thread for more details about handling Exceptions in .NET core.

    Also, you may want to see Set up Application Insights: Diagnose exceptions and blog post for more details on configuring Application Insights.

     

    Hope this helps.

     

    Regards,

    Ashok

    ___________________________________________________________________

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer so that other customers can benefit from it.

    Thursday, October 20, 2016 7:38 AM
    Moderator