Example #1
0
        static void Main()
        {
            #region Log init

            var severity = ConfigurationManager.AppSettings.Get("LogSeverity");
            SingletonLogger.Instance.Severity = (LogSeverity)Enum.Parse(typeof(LogSeverity), severity, true);
            ILog log = new ObserverLogToConsole();
            SingletonLogger.Instance.Attach(log);
            log = new ObserverLogToFile("filename");
            SingletonLogger.Instance.Attach(log);

            #endregion

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
Example #2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Code that runs on application startup
            // 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 debugger console (output window). 
            // Btw: the attach operation is the Observer pattern.
            ILog log = new ObserverLogToConsole();
            SingletonLogger.Instance.Attach(log);

            // Send log messages to a file
            log = new ObserverLogToFile("filename");
            SingletonLogger.Instance.Attach(log);
            
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                new SmsService() 
            };
            ServiceBase.Run(ServicesToRun);
        }