/// <summary> /// Initializes logging facility with severity level and observer(s). /// Private helper method. /// </summary> private void InitializeLogger() { // Read and assign application wide logging severity string severity = ConfigurationManager.AppSettings.Get("LogSeverity"); SingletonLogger.Instance.Severity = (LogSeverity)Enum.Parse(typeof(LogSeverity), severity, true); // Send log messages to database (observer pattern) ILog log = new ObserverLogToDatabase(); SingletonLogger.Instance.Attach(log); // Send log messages to email (observer pattern) string from = "*****@*****.**"; string to = "*****@*****.**"; string subject = "Webmaster: please review"; string body = "email text"; SmtpClient smtpClient = new SmtpClient("mail.yourcompany.com"); log = new ObserverLogToEmail(from, to, subject, body, smtpClient); SingletonLogger.Instance.Attach(log); // Send log messages to a file log = new ObserverLogToFile(@"C:\Temp\DoFactory.log"); SingletonLogger.Instance.Attach(log); // Send log message to event log log = new ObserverLogToEventlog(); SingletonLogger.Instance.Attach(log); }
private void InitializeLogger() { // send log messages to email (observer pattern) string from = "*****@*****.**"; string to = "*****@*****.**"; string subject = "Webmaster: please review"; string body = "email text"; var smtpClient = new SmtpClient("mail.yourcompany.com"); var logEmail = new ObserverLogToEmail(from, to, subject, body, smtpClient); Logger.Instance.Attach(logEmail); // send log messages to a file var logFile = new ObserverLogToFile(@"C:\Temp\Error.log"); Logger.Instance.Attach(logFile); // send log messages to database (observer pattern) var logDatabase = new ObserverLogToDatabase(); Logger.Instance.Attach(logDatabase); }
public static void InitLog(string logPath) { LogPath = logPath; ILog log = new ObserverLogToFile(LogPath + @"\MarketService.log"); SingletonLogger.Instance.Attach(log); }
public static void InitializeLogger() { // Read and assign application wide logging severity string severity = Core.Settings.LogSeverity; SingletonLogger.Instance.Severity = (LogSeverity)Enum.Parse(typeof(LogSeverity), severity, true); // Send log messages to debugger console (output window). // Btw: the attach operation is the Observer pattern. ILog log = new ObserverLogToConsole(); SingletonLogger.Instance.Attach(log); // Send log messages to email (observer pattern) //string from = "*****@*****.**"; //string to = "*****@*****.**"; //string subject = "Webmaster: please review"; //string body = "email text"; //var smtpClient = new SmtpClient("mail.yourcompany.com"); //log = new ObserverLogToEmail(from, to, subject, body, smtpClient); //SingletonLogger.Instance.Attach(log); // Other log output options //// Send log messages to a file log = new ObserverLogToFile(); SingletonLogger.Instance.Attach(log); //// Send log message to event log //log = new ObserverLogToEventlog(); //SingletonLogger.Instance.Attach(log); //// Send log messages to database (observer pattern) //log = new ObserverLogToDatabase(); //SingletonLogger.Instance.Attach(log); }
public static void InitLog() { ILog log = new ObserverLogToFile(@"DoFactory.log"); SingletonLogger.Instance.Attach(log); }
private static void Main(string[] args) { // 將App.config檔裡面DevExpress的設定讀進來 DevExpress.XtraEditors.WindowsFormsSettings.LoadApplicationSettings(); #region Log設定 SingletonLogger.Instance.Severity = (LogSeverity)Enum.Parse(typeof(LogSeverity), SettingDragons.Instance.Setting.Log.LogSeverity, true); ILog log = new ObserverLogToDatabase(); SingletonLogger.Instance.Attach(log); log = new ObserverLogToFile("Debug.txt"); SingletonLogger.Instance.Attach(log); log = new ObserverLogToConsole(); SingletonLogger.Instance.Attach(log); #endregion Log設定 #region GlobalSetting SystemStatus.SystemType = SystemType.CI; ConnectionInfo connectionInfo = SettingDragons.Instance.GetConnectionInfo(SettingDragons.Instance.Setting.Database.CiUserAp); GlobalDaoSetting.Set(connectionInfo); #if DEBUG GlobalInfo.USER_ID = "I0001"; GlobalInfo.USER_NAME = "菲魯特"; GlobalInfo.USER_DPT_ID = "J"; GlobalInfo.USER_DPT_NAME = "資訊規劃部"; #endif string reportDirectoryPath = ""; if (GlobalDaoSetting.GetConnectionInfo.ConnectionName == "CIN2" || Application.StartupPath.IndexOf(@"C:\CI") < 0) { reportDirectoryPath = Path.Combine(Application.StartupPath, "Report", DateTime.Now.ToString("yyyyMMdd")); } else { reportDirectoryPath = Path.Combine(Application.StartupPath, "Excel_Report", DateTime.Now.ToString("yyyyMMdd")); } string excelTemplateDirectoryPath = ""; excelTemplateDirectoryPath = Path.Combine(Application.StartupPath, "Excel_Template"); string batchErrSPDirectoryPath = Path.Combine(Application.StartupPath, "ErrSP"); Directory.CreateDirectory(reportDirectoryPath); GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH = reportDirectoryPath; Directory.CreateDirectory(excelTemplateDirectoryPath); GlobalInfo.DEFAULT_EXCEL_TEMPLATE_DIRECTORY_PATH = excelTemplateDirectoryPath; Directory.CreateDirectory(batchErrSPDirectoryPath); GlobalInfo.DEFAULT_BATCH_ErrSP_DIRECTORY_PATH = batchErrSPDirectoryPath; #endregion GlobalSetting Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += new ThreadExceptionEventHandler(UIThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // 如果有傳參數進來 if (args.Length != 0) { string userID = args[0]; string userName = args[1]; string txnID = args[2]; string txnName = args[3]; GlobalInfo.USER_ID = userID; GlobalInfo.USER_NAME = userName; if (userID.ToUpper() == GlobalDaoSetting.GetConnectionInfo.ConnectionName) { GlobalInfo.USER_DPT_ID = " "; } else { DataTable user = new UPF().ListDataByUserId(userID); GlobalInfo.USER_DPT_ID = user.Rows[0]["UPF_DPT_ID"].AsString(); } Application.Run(new FormMain(txnID, txnName)); } else { #if DEBUG Application.Run(new FormMain()); #else Application.Run(new FormLogin()); #endif } }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string sUsuario = ""; string sBaseDatos = ""; String sModoPrueba = ""; string severity = ConfigurationManager.AppSettings.Get("LogSeverity"); SingletonLogger.Instance.Severity = (LogSeverity)Enum.Parse(typeof(LogSeverity), severity, true); // Send log messages to a file ILog log = new ObserverLogToFile(Application.StartupPath + @"\Log_VKIVA.log"); SingletonLogger.Instance.Attach(log); Autenticacion oAut = new Autenticacion(); //args = new string[] { "-DMGMLOC", "-SSYSADM", "-SSYSADM" }; if (args.Length != 0) { sUsuario = args[1].Substring(2, args[1].Length - 2).Trim(); sBaseDatos = args[0].Substring(2, args[0].Length - 2).Trim(); Usuario.userName = sUsuario; if (args.Length > 3) { sModoPrueba = args[3]; } if ((sModoPrueba == "") && (!oAut.licenciaActiva(sBaseDatos, "VKIVA")))//"VKIVA" { MessageBox.Show("No cuenta una licencia para abrir esta aplicación.", "Acceso Denegado", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (oAut.probarConexion(sBaseDatos, true)) { if (oAut.validarAcceso(sUsuario, "VKIVA")) { Application.Run(new frmPrincipal(oAut.StringConexion)); } else { MessageBox.Show("No cuenta con permisos para abrir esta aplicación.", "Acceso Denegado", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show(oAut.Mensaje); } } else { //Mostrar ventana de loguin Login oLogin = new Login("VKIVA"); oLogin.ValidarLicencia = false; oLogin.ValidarAcceso = false; oLogin.ShowDialog(); Usuario.userName = oLogin.Usuario; if (oLogin.Logeado) { Application.Run(new frmPrincipal(oLogin.StringConexion)); } } }