Example #1
0
 public void EmitLog(LogEntry log)
 {
     if (m_InitOK == false)
     {
         return;
     }
     m_Method.Invoke(m_QueueObj, new object[] { log });
 }
Example #2
0
 public void EmitLog(LogEntry log)
 {
     RestClient client = new RestClient();
     client.InvokeAsync(m_Url, log, m_Method, m_Format, ex =>
     {
         string message = string.Format("Write log failed.\r\n\r\n Error Info: {0}. \r\n\r\n Log Type: {1}. \r\n\r\n Log Info: {2}", ex.ToString(), this.GetType().AssemblyQualifiedName, log.SerializationWithoutException());
         Logger.WriteEventLog(message, System.Diagnostics.EventLogEntryType.Error);
     });
 }
Example #3
0
 public void EmitLog(LogEntry log)
 {
     SoapEntityMapping.Add<LogEntry>();
     SoapEntityMapping.Add<ExtendedPropertyData>();
     SoapClient.InvokeAsync(m_Url, m_MethodName, null, ex =>
     {
         string message = string.Format("Write log failed.\r\n\r\n Error Info: {0}. \r\n\r\n Log Type: {1}. \r\n\r\n Log Info: {2}", ex.ToString(), this.GetType().AssemblyQualifiedName, log.SerializationWithoutException());
         Logger.WriteEventLog(message, System.Diagnostics.EventLogEntryType.Error);
     }, log);
 }
Example #4
0
        public void EmitLog(LogEntry log)
        {
            if (!Directory.Exists(m_LogFolderPath))
            {
                Directory.CreateDirectory(m_LogFolderPath);
            }

            WriteToFile(log.SerializationWithoutException(),
                Path.Combine(m_LogFolderPath, DateTime.Now.ToString("yyyy-MM-dd") + ".txt"));
        }
Example #5
0
        public static string WriteLog(string content, string category = null, string referenceKey = null, List<KeyValuePair<string, object>> extendedProperties = null)
        {
            LogEntry log = new LogEntry();
            log.ServerTime = DateTime.Now;
            log.LogID = Guid.NewGuid();
            log.Source = GetSource();
            log.RequestUrl = GetRequestUrl();
            log.UserHostName = GetUserHostName();
            log.UserHostAddress = GetUserHostAddress();
            log.ServerIP = GetServerIP();
            try
            {
                log.ServerName = Dns.GetHostName();
            }
            catch { }
            string p_name;
            log.ProcessID = GetProcessInfo(out p_name);
            log.ProcessName = p_name;
            try
            {
                log.ThreadID = Thread.CurrentThread.ManagedThreadId;
            }
            catch { }

            log.Category = category;
            log.Content = content;
            log.ReferenceKey = referenceKey;
            if (extendedProperties != null && extendedProperties.Count > 0)
            {
                foreach (var p in extendedProperties)
                {
                    log.AddExtendedProperty(p.Key, p.Value);
                }
            }

            return WriteLog(log);
        }
Example #6
0
 private static string WriteLog(LogEntry log)
 {
     List<ILogEmitter> logEmitterList;
     try
     {
         logEmitterList = EmitterFactory.Create();
     }
     catch(Exception ex)
     {
         string message = string.Format("Failed to create log emitter instance.\r\n\r\n Error Info: {0}. \r\n\r\n Log Info: {1}", ex.ToString(), log.SerializationWithoutException());
         WriteEventLog(message, EventLogEntryType.Error);
         return log.LogID.ToString();
     }
     return WriteLog(log, logEmitterList);
 }
Example #7
0
        private static string WriteLog(LogEntry log, List<ILogEmitter> logEmitterList)
        {
            if (logEmitterList == null || logEmitterList.Count <= 0)
            {
                return log.LogID.ToString();
            }
            try
            {
                foreach (var logEmitter in logEmitterList)
                {
                    if (logEmitter == null)
                    {
                        continue;
                    }
                    try
                    {
                        logEmitter.EmitLog(log);
                    }
                    catch (Exception ex)
                    {
                        string message = string.Format("Write log failed.\r\n\r\n Error Info: {0}. \r\n\r\n Log Type: {1}. \r\n\r\n Log Info: {2}", ex.ToString(), logEmitter.GetType().AssemblyQualifiedName, log.SerializationWithoutException());
                        Logger.WriteEventLog(message, EventLogEntryType.Error);
                    }
                }
            }
            catch(Exception ex)
            {
                string message = string.Format("Write log failed.\r\n\r\n Error Info: {0}. \r\n\r\n Log Info: {1}", ex.ToString(), log.SerializationWithoutException());
                Logger.WriteEventLog(message, EventLogEntryType.Error);
            }

            return log.LogID.ToString();
        }
Example #8
0
 public void EmitLog(LogEntry log)
 {
     WriteEventLog(m_LogName, log.SerializationWithoutException(), EventLogEntryType.Error);
 }