I'm using the LoadBalancing project (v3.4.31.10808) and I'm trying to register an UnhandledEceptionEventHandler. I want to log unhandled exceptions using a custom log4net appender (SlackAppender).
I know Photon logs unhandled exceptions to PhotonCLR.log, but adding my custom appender to the Photon.local.log4net file but when I did that, nothing logged (presumably because whatever references Photon.local.log4net doesn't have any clue about my appender).
Then, I tried updating the log4net config file (that gets deployed to the LoadBalancing application's directory) to use my appender. The normal logging that config file handles seems to go through, which leads me to believe the issue is not with log4net, but maybe with how I'm trying to capture unhandled exceptions in my code.
I added this line to my MasterApplication#Setup class:
That method simply looks like this:
I know Photon logs unhandled exceptions to PhotonCLR.log, but adding my custom appender to the Photon.local.log4net file but when I did that, nothing logged (presumably because whatever references Photon.local.log4net doesn't have any clue about my appender).
Then, I tried updating the log4net config file (that gets deployed to the LoadBalancing application's directory) to use my appender. The normal logging that config file handles seems to go through, which leads me to believe the issue is not with log4net, but maybe with how I'm trying to capture unhandled exceptions in my code.
I added this line to my MasterApplication#Setup class:
AppDomain.CurrentDomain.UnhandledException += MyExceptionHandler;
That method simply looks like this:
private static void MyExceptionHandler(object sender, UnhandledExceptionEventArgs args)
{
Exception e = (Exception)args.ExceptionObject;
log.Info("Unhandled exception logger called...", e);
log.Error("Unhandled exception occurred in our code...", e);
}
However, when I put a breakpoint inside that method, it's never called even when I explicitly throw an exception in CreatePeer of that same class. Is this somehow related to different app domains and attaching my event to the wrong one?