Closed
Description
The Main method in Program.cs in my dotnet core web api project has the following code.
public static void Main(string[] args)
{
var logger = LogManager.LoadConfiguration("nlog.config").GetCurrentClassLogger();
try
{
BuildWebHost(args).Run();
}
catch (Exception ex)
{
//NLog: catch setup errors
logger.Error(ex, "An exception occurred during application start.");
throw;
}
}
I also setup an exception handling middleware like this:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseResponseCompression();
app.UseMiddleware(typeof(HandleExceptionMiddleware));
app.UseMvc();
}
Should i also add a AppDomain.CurrentDomain.UnhandledException
? to the Main
method - since dotnet core web api is a console application?. Do I loose/gain any chances of trapping exceptions without this?