Ejemplo n.º 1
0
        private void OnException(object sender, UnhandledExceptionEventArgs e)
        {
            string report = e.ExceptionObject != null?e.ExceptionObject.ToString() : "Exception object is null!";

            try {
                using (FileStream stream = new FileStream(FileErrorPath(), FileMode.Create)) {
                    Log           log        = _exceptionHandler.GetLog(true, report);
                    XmlSerializer serializer = new XmlSerializer(typeof(Log));
                    serializer.Serialize(stream, log);
                }
            } catch (Exception ex) {
                string logReport = "Logger error: " + ex.ToString();
                logReport += Environment.NewLine;
                logReport += report;

                File.WriteAllText(FileErrorPath(), logReport);
            }
        }