Ejemplo n.º 1
0
        private static void LogInfoMessage(DateTime timestamp, CommonEnums.LogMessageType messageType, string source, string message, string loginId = null)
        {
            //prepend application name to source
            source = string.Format("{0}: {1}", ApplicationName, source);
            if (!string.IsNullOrEmpty(loginId))
            {
                source += string.Format(" [{0}]", loginId);
            }

            Utils.WriteToEventLog(source, message, System.Diagnostics.EventLogEntryType.Information);
        }
Ejemplo n.º 2
0
        private static void LogErrorMessage(CommonEnums.LogMessageType messageType, string source, string message, Exception ex, bool bAsync = false, string loginId = null)
        {
            DateTime now = DateTime.Now;

            if (bAsync)
            {
                Task.Factory.StartNew(() => LogErrorMessage(now, messageType, source, message, ex, loginId));
            }
            else
            {
                LogErrorMessage(now, messageType, source, message, ex, loginId);
            }
        }
Ejemplo n.º 3
0
        private static void LogErrorMessage(DateTime timestamp, CommonEnums.LogMessageType messageType, string source, string message, Exception ex, string loginId = null)
        {
            //prepend application name to source
            source = string.Format("{0}: {1}", ApplicationName, source);
            if (!string.IsNullOrEmpty(loginId))
            {
                source += string.Format(" [{0}]", loginId);
            }

            Utils.WriteToEventLog(
                source,
                string.Format("{0}: {1} {2} Stack Trace: {3}", message, ex.Message, Environment.NewLine, ex.StackTrace),
                System.Diagnostics.EventLogEntryType.Error);
            if (ex.InnerException != null)
            {
                Utils.WriteToEventLog(
                    source,
                    string.Format("{0}: {1} {2} Stack Trace: {3}", message + " [Inner Exception]", ex.InnerException.Message, Environment.NewLine, ex.InnerException.StackTrace),
                    System.Diagnostics.EventLogEntryType.Error);
            }
        }