コード例 #1
0
        /// <summary>
        /// Sends a log request via email.
        /// </summary>
        /// <remarks>
        /// Actual email 'Send' calls are commented out.
        /// Uncomment if you have the proper email privileges.
        /// </remarks>
        /// <param name="sender">Sender of the log request.</param>
        /// <param name="e">Parameters of the log request.</param>
        public void Log(object sender, LogEventArgs e)
        {
            string message = "[" + e.Date.ToString() + "] " +
               e.SeverityString + ": " + e.Message;

            // Commented out for now. You need privileges to send email.
            // _smtpClient.Send(_from, _to, _subject, body);
        }
コード例 #2
0
        /// <summary>
        /// Write a log request to a file.
        /// </summary>
        /// <param name="sender">Sender of the log request.</param>
        /// <param name="e">Parameters of the log request.</param>
        public void Log(object sender, LogEventArgs e)
        {
            if (e.Exception != null)
            {
                LogController.WriteLog(e.Exception);
            }

            // PhatVT Them
            if (!string.IsNullOrEmpty(e.Message))
            {
                LogController.WriteLog(e.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Write a log request to the event log.
        /// </summary>
        /// <remarks>
        /// Actual event log write entry statements are commented out.
        /// Uncomment if you have the proper privileges.
        /// </remarks>
        /// <param name="sender">Sender of the log request.</param>
        /// <param name="e">Parameters of the log request.</param>
        public void Log(object sender, LogEventArgs e)
        {
            string message = "[" + e.Date.ToString() + "] " +
                e.SeverityString + ": " + e.Message;

            var eventLog = new EventLog();
            eventLog.Source = "Patterns In Action";

            // Map severity level to an Windows EventLog entry type
            var type = EventLogEntryType.Error; 
            if (e.Severity < LogSeverity.Warning) type = EventLogEntryType.Information;
            if (e.Severity < LogSeverity.Error) type = EventLogEntryType.Warning;

            // In try catch. You will need proper privileges to write to eventlog.
            try { eventLog.WriteEntry(message, type); }
            catch { /* do nothing */ }
        }
コード例 #4
0
ファイル: SingletonLogger.cs プロジェクト: ronymaychan/demos
 /// <summary>
 /// Invoke the Log event.
 /// </summary>
 /// <param name="e">Log event parameters.</param>
 public void OnLog(LogEventArgs e)
 {
     if (Log != null)
     {
         Log(this, e);
     }
 }