Exemplo n.º 1
0
 public static void Log(LogCategories category, LogEventID id, TraceEventType type, string message)
 {
     LogEntry entry = new LogEntry();
     entry.EventId = (int)id;
     entry.Categories.Add(category.ToString());
     entry.Message = message;
     entry.Severity = type;
     Logger.Write(entry);
 }
Exemplo n.º 2
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteStartElement("log");
     writer.WriteAttributeString("LogGUID", LogGUID);
     writer.WriteAttributeString("LogFileID", LogFileID);
     writer.WriteAttributeString("LogTypeKey", LogTypeKey);
     writer.WriteAttributeString("LogUserID", LogUserID.ToString());
     writer.WriteAttributeString("LogEventID", LogEventID.ToString());
     writer.WriteAttributeString("LogUserName", LogUserName);
     writer.WriteAttributeString("LogPortalID", LogPortalID.ToString());
     writer.WriteAttributeString("LogPortalName", LogPortalName);
     writer.WriteAttributeString("LogCreateDate", LogCreateDate.ToString());
     writer.WriteAttributeString("LogCreateDateNum", LogCreateDateNum.ToString());
     writer.WriteAttributeString("BypassBuffering", BypassBuffering.ToString());
     writer.WriteAttributeString("LogServerName", LogServerName);
     writer.WriteAttributeString("LogConfigID", LogConfigID);
     LogProperties.WriteXml(writer);
     writer.WriteEndElement();
 }
Exemplo n.º 3
0
 public static void Error(LogEventID eventId, Exception ex, string message)
 {
     string message2 = message + "\r\n" + ex.ToString();
     WriteEventLog(EventLogEntryType.Error, message2, eventId);
 }
Exemplo n.º 4
0
 public static void Error(LogEventID eventId, string message)
 {
     WriteEventLog(EventLogEntryType.Error, message, eventId);
 }
Exemplo n.º 5
0
        private static void WriteEventLogInner(EventLogEntryType entryType, string message, LogEventID eventId, int repeat)
        {
            // NextVersion
            //if (repeat != 1) {
            //    message = string.Format("!!!Repeat ({0}) times within last 5 second.\r\n", repeat, message);
            //}
            EventLog.WriteEntry(_eventSource, message, entryType, (int)eventId);

            SystemLogEvent evt = new SystemLogEvent();
            evt.ComputerName = ServiceEnviornment.ComputerName;
            evt.ServiceName = ServiceEnviornment.ServiceName;
            evt.Time = DateTime.Now;
            evt.Message = message;
            evt.Level = GetTracingLevel(entryType);
            evt.EventId = eventId;
            evt.Repeat = repeat;

            TracingManager.Enqueue(evt);
        }
Exemplo n.º 6
0
        private static void WriteEventLog(EventLogEntryType entryType, string message, LogEventID eventId)
        {
            try {
                if (_eventSource == null) {
                    lock (_syncRoot) {
                        if (_eventSource == null) {
                            try {
                                _eventSource = ServiceEnviornment.ServiceName + "-Service";
                            } catch (Exception) {
                                _eventSource = null;
                            }
                            if (string.IsNullOrEmpty(_eventSource))
                                _eventSource = Process.GetCurrentProcess().ProcessName;

                            EnsureEventSource(_eventSource);
                        }
                    }
                }

                WriteEventLogInner(entryType, message, eventId, 1);
                //
                // NextVersion
                //int repeat;
                //if (TracingManager.AntiRepeat) {
                //    if (!AntiRepeater.IsRepeated(out repeat))
                //		WriteEventLogInner(entryType, message, eventId, repeat);
                //} else {
                //	WriteEventLogInner(entryType, message, eventId, 1);
                //}
            } catch (Exception ex) {
                Unexcepted(ex);
            }
        }
Exemplo n.º 7
0
 public static void Warn(LogEventID eventId, string message)
 {
     WriteEventLog(EventLogEntryType.Warning, message, eventId);
 }
Exemplo n.º 8
0
 public static void Info(LogEventID eventId, string format, params object[] args)
 {
     string message = TracingHelper.FormatMessage(format, args);
     WriteEventLog(EventLogEntryType.Information, message, eventId);
 }
Exemplo n.º 9
0
        public static void Error(LogEventID eventId, string format, params object[] args)
        {
            string message = TracingHelper.FormatMessage(format, args);

            WriteEventLog(EventLogEntryType.Error, message, eventId);
        }
Exemplo n.º 10
0
 public static void Error(LogEventID eventId, string message)
 {
     WriteEventLog(EventLogEntryType.Error, message, eventId);
 }
Exemplo n.º 11
0
 public static void Warn(LogEventID eventId, string message)
 {
     WriteEventLog(EventLogEntryType.Warning, message, eventId);
 }
Exemplo n.º 12
0
 public static void Info(LogEventID eventId, string message)
 {
     WriteEventLog(EventLogEntryType.Information, message, eventId);
 }
Exemplo n.º 13
0
        private static void WriteEventLogInner(EventLogEntryType entryType, string message, LogEventID eventId, int repeat)
        {
            // NextVersion
            //if (repeat != 1) {
            //    message = string.Format("!!!Repeat ({0}) times within last 5 second.\r\n", repeat, message);
            //}
            EventLog.WriteEntry(_eventSource, message, entryType, (int)eventId);

            SystemLogEvent evt = new SystemLogEvent();

            evt.ComputerName = ServiceEnvironment.ComputerName;
            evt.ServiceName  = ServiceEnvironment.ServiceName;
            evt.Time         = DateTime.Now;
            evt.Message      = message;
            evt.Level        = GetTracingLevel(entryType);
            evt.EventId      = eventId;
            evt.Repeat       = repeat;

            TracingManager.Enqueue(evt);
        }
Exemplo n.º 14
0
        private static void WriteEventLog(EventLogEntryType entryType, string message, LogEventID eventId)
        {
            try {
                if (_eventSource == null)
                {
                    lock (_syncRoot) {
                        if (_eventSource == null)
                        {
                            try {
                                _eventSource = ServiceEnvironment.ServiceName + "-Service";
                            } catch (Exception) {
                                _eventSource = null;
                            }
                            if (string.IsNullOrEmpty(_eventSource))
                            {
                                _eventSource = Process.GetCurrentProcess().ProcessName;
                            }

                            EnsureEventSource(_eventSource);
                        }
                    }
                }

                WriteEventLogInner(entryType, message, eventId, 1);
                //
                // NextVersion
                //int repeat;
                //if (TracingManager.AntiRepeat) {
                //    if (!AntiRepeater.IsRepeated(out repeat))
                //		WriteEventLogInner(entryType, message, eventId, repeat);
                //} else {
                //	WriteEventLogInner(entryType, message, eventId, 1);
                //}
            } catch (Exception ex) {
                Unexcepted(ex);
            }
        }
Exemplo n.º 15
0
 public static void Error(LogEventID eventId, Exception ex, string format, params object[] args)
 {
     string message = TracingHelper.FormatMessage(format, args) + "\r\n" + ex.ToString();
     WriteEventLog(EventLogEntryType.Error, message, eventId);
 }
Exemplo n.º 16
0
 public static void Info(LogEventID eventId, string message)
 {
     WriteEventLog(EventLogEntryType.Information, message, eventId);
 }
Exemplo n.º 17
0
        public static void Error(LogEventID eventId, Exception ex, string message)
        {
            string message2 = message + "\r\n" + ex.ToString();

            WriteEventLog(EventLogEntryType.Error, message2, eventId);
        }
Exemplo n.º 18
0
        public static void Error(LogEventID eventId, Exception ex, string format, params object[] args)
        {
            string message = TracingHelper.FormatMessage(format, args) + "\r\n" + ex.ToString();

            WriteEventLog(EventLogEntryType.Error, message, eventId);
        }
Exemplo n.º 19
0
 public static void Record(LogEventID id)
 {
 }