Created
January 3, 2017 16:07
-
-
Save RdlP/fc7f305d895ade756cad695f1e1851e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| // Logea las excepciones no controladas. | |
| AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(unhandledException); | |
| } | |
| static void unhandledException(object sender, UnhandledExceptionEventArgs args) | |
| { | |
| Exception e = (Exception)args.ExceptionObject; | |
| Console.WriteLine("MyHandler caught : " + e.Message); | |
| Console.WriteLine("Runtime terminating: {0}", args.IsTerminating); | |
| Console.WriteLine("StackTrace: {0}", e.StackTrace); | |
| using (System.IO.StreamWriter file = new System.IO.StreamWriter(Directory.GetCurrentDirectory() + @"\log.txt", true)) | |
| { | |
| DateTimeOffset date = DateTimeOffset.Now; | |
| file.WriteLine("========={0:MM/dd/yy H:mm:ss zzz}=========", date); | |
| file.WriteLine(e.Message); | |
| file.WriteLine(args.IsTerminating); | |
| file.WriteLine(e.StackTrace); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment