프로젝트

일반

사용자정보

개정판 a7346d3c

IDa7346d3c38bf5f820b53719a0018a7da392642a0
상위 48133b12
하위 26f20003, f20989cc

백흠경이(가) 5년 이상 전에 추가함

issue #934: save un-handled exception to database

Change-Id: I1f8836956ac96821089f0c085cba4a06adfcf667

차이점 보기:

KCOM/App.xaml.cs
14 14
using System.ServiceModel;
15 15
using System.Windows;
16 16
using System.Xml;
17
using log4net;
17 18

  
19
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
18 20
namespace KCOM
19 21
{
20 22
    public class OpenProperties
......
47 49
        public static string Custom_ViewInfoId;
48 50
        public static bool ParameterMode = false;
49 51

  
52
        /// <summary>
53
        /// logger
54
        /// </summary>
55
        public static ILog log = null;
56

  
57
        /// <summary>
58
        /// Application Data Folder
59
        /// </summary>
60
        public static string AppDataFolder
61
        {
62
            get
63
            {
64
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS");
65
            }
66
        }
50 67

  
51 68
        public static RestSharp.RestClient BaseClient { get; set; }
52 69
        public static IKCOM.KCOM_SystemInfo SystemInfo { get; set; }
......
68 85
        protected override void OnStartup(StartupEventArgs e)
69 86
        {
70 87
            try
71
            {               
88
            {
89
                /// create log database and table
90
                using (IAbstractDatabase database = new AppSQLiteDatabase() { FilePath = Path.Combine(AppDataFolder, "log4net.db") })
91
                {
92
                    string sSql = "CREATE TABLE IF NOT EXISTS Log (LogId INTEGER PRIMARY KEY,Date DATETIME NOT NULL,Level VARCHAR(50) NOT NULL,Logger VARCHAR(255) NOT NULL,Message TEXT DEFAULT NULL,StackTrace TEXT DEFAULT NULL);";
93
                    database.ExecuteNonQuery(sSql);
94
                }
95
                /// up to here
96
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
97
                log4net.GlobalContext.Properties["LogFilePath"] = Path.Combine(AppDataFolder, "log4net.db");
98
                log = LogManager.GetLogger(typeof(App));
99

  
72 100
                splash.Show(false, false);
73 101

  
74 102
                if (e.Args.Count() > 0)
......
187 215
                MessageBox.Show("Err" + ex.Message);
188 216
            }
189 217
        }
190
        
218

  
219
        /// <summary>
220
        /// log unhandled exception
221
        /// </summary>
222
        /// <author>humkyung</author>
223
        /// <date>2019.05.21</date>
224
        /// <param name="sender"></param>
225
        /// <param name="e"></param>
226
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
227
        {
228
            try
229
            {
230
                App.log.Fatal(e.ExceptionObject as Exception);
231
            }
232
            catch (Exception ex)
233
            {
234
                Console.WriteLine(ex.InnerException.ToString());
235
            }
236
            finally
237
            {
238
                Environment.Exit(0);
239
            }
240
        }
241

  
191 242
        protected void UpdateCheck(StartupEventArgs e)
192 243
        {          
193 244
            try

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)