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);
        }
Beispiel #2
0
        /// <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);
        }
        // initializes logging facility with severity level and observer(s).

        private void InitializeLogger()
        {
            // set system wide severity

            Logger.Instance.Severity = LogSeverity.Error;

            // send log messages to debugger console (output window)
            // Note: the attach operation is the Observer pattern

            var logConsole = new ObserverLogToConsole();

            Logger.Instance.Attach(logConsole);

            // also 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);

            // Other log output options (commented out)

            // send log messages to a file

            //var logFile = new ObserverLogToFile(@"C:\Temp\Error.log");
            //Logger.Instance.Attach(logFile);

            // send log message to event log

            //var logEvent = new ObserverLogToEventlog();
            //Logger.Instance.Attach(logEvent);

            // send log messages to database (observer pattern)

            //var logDatabase = new ObserverLogToDatabase();
            //Logger.Instance.Attach(logDatabase);
        }
Beispiel #4
0
        /// <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);

            SingletonLogger.Instance.Severity = LogSeverity.Debug | LogSeverity.Error | LogSeverity.Fatal | LogSeverity.Info;

            // Send log messages to debugger console (output window).
            // Btw: the attach operation is the Observer pattern.
            Log.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(@"C:\Temp\DoFactory.log");
            //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);
        }