The docs for this method say:
Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and optional exception information in error reporting to Microsoft.
But what about when deployed to a Linux environment where there's no EventLog or Windows Error Reporting?
I want the benefit of being able to immediately terminate the console app in this way, but it's unclear if this is the right method to use. Is there a better approach for Linux?
The plan is to have my console app running in a Linux container. I'd like the app to be able to terminate, and thus cause the container to terminate, so the infrastructure can spin up a new one. However, I am just getting started with Docker (and my Linux skills are very rusty). So I'm at a loss here...
I will likely have to spin up a small sample and just tinker around, but was hoping to ask the question here in case anyone could provide a quicker answer.
TIA
Nothing like trying it out!
using System;
namespace testing
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
System.Environment.FailFast("oh shoot");
Console.WriteLine("Bye!");
}
}
}
Gives me
/tmp/testing$ dotnet run
Hello World!
FailFast:
oh shoot
at System.Environment.FailFast(System.String, System.Exception)
at System.Environment.FailFast(System.String)
at testing.Program.Main(System.String[])
I did not see any additional log messages in anything in /var/log
. So I guess it just exists fast and dumps a log to the console.