Exception handling logging ASP.NET Core - asp.net-core-6.0

Can anyone please share an exception handling logging snippet that can save data in the Database in ASP.Net Core 6.
Thanks.

Related

ASP.NET Core Application Insights adaptive sampling

TL;DR: Does ExcludedTypes in Microsoft.ApplicationInsights.AspNetCore SDK default to Exception and Trace?
I am running an ASP.NET Core 2.2 app with version 2.6.1 Microsoft.ApplicationInsights.AspNetCore SDK. I am reading: https://learn.microsoft.com/en-us/azure/azure-monitor/app/sampling#configuring-adaptive-sampling-for-aspnet-applications where they write that the default values for ExcludedTypes is Trace and Exception, which is just the way i like it, but I am wondering, since the default values is for ASP.NET (actually specified in the application insights config for the host), if these default values also apply for ASP.NET Core applications that doesnt have an application insights config file (all config is done through code).
I know that the SDK is open sourced, but I haven't been able to search through it and find the initial values: https://github.com/microsoft/ApplicationInsights-aspnetcore. Maybe I am just searching for the wrong things.
Update:
Yes, the default ExcludedTypes for asp.net core is Event. There'are 2 places mentionded that:
1.In this article, it says "In ASP.NET Core, exact same default behavior is enabled in code.":
2.In the source code, you can find it's defined here:
First, the default values for ExcludedTypes is not Trace and Exception, it is Event. There is a GitHub issue for that. And I also tested it myself, the default ExcludedType is Event indeed.
For asp.net core, the default ExcludedType should be same as asp.net, you can take a look at this section of the article you provided. I'll try to go through the code to find out what's in the code for asp.net core and will update you later.

Error using elastic database transaction with sql azure

I have 2 SQL Azure DB's (V12) within a single server and wants the transaction to be atomic. Trying to do what is mentioned here.
I get below exception while trying to wrap the transactions in a single transaction scope. The project targets .net version 4.6.
What am I missing here?
Error message (in case image doesn't appear on your end): "The service has encountered an error processing your request. Please try again. Error code 8510.
A severe error occurred on the current command. The results, if any, should be discarded."
Thanks!
Can you check that you are running with .NET 4.6.1? You need 4.6.1 or later and the exceptions looks like you are running on an earlier .NET version than that.
Thanks,
Torsten

ASP.NET RC1 Update 1 in Azure Web Site

I have my startup developed in ASP.NET Core RC1 and published in Azure like a web site.
Sometimes I don't know why, the web app is down. I don't know what exactly happens, but I have an error in GCI like this:
The specified CGI application encountered an error and the server
terminated the process.
I have about 100K users, but it happens in hours that I don't have a lot of users using the web.
Here you have some screenshot about the errors:
I have created an API in a version of ASP.NET 4.5 to upload images to the platform (I know about the error of uploading files in Kestrel) and I'm in a point where I don't know what happens.
I'm using Application Insight in my platform, and I have received an alert, about the service:
90% of all the failed requests had this exception: Exception
method: System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
Exception type: Microsoft.AspNet.Server.Kestrel.Networking.UvException
I am totally frustrated about how to solve the error. My web app was totally fine when I was working in ASP.NET 4.5 in AWS, but now, I have a lot of problems...
What can I do? Any idea or help? Thanks.

How to get Windows azure to give me more useful error information

I've been experimenting with the new windows azure website feature, and im getting http 500 internal server errors, but the logs are giving me very generic messages, I "think" its a problem with database connections, as everything runs fine locally. Is there some way to get more usefull error messages from azure ?
Im using C# .net 4.0 and mvc 3
Can you adjust the custom errors section in the web.config to give you detailed errors all the time?

Connect Pantheios logging in a DLL to the main application's logging

Here's the situation: I'm working on a MFC application and want to integrate some logging capabilities into it. I did some research and settled on Pantheios since it seems to be regarded as the best logging API out there. I had no problems getting simple logging up and running - I even threw in some callback stuff to change the formatting of the output.
My application will be making use of several DLLs. These are DLLs that I am actively developing and would like to integrate logging into them as well. Ideally all the logging from these DLLs will be routed into the main application log - but I can't figure out how to do that using Pantheios. I can have them log to their own files but I can't figure out how to attach them to the main application log.
Any ideas?

Resources