public void EmitLog(LogEntry log) { if (m_InitOK == false) { return; } m_Method.Invoke(m_QueueObj, new object[] { log }); }
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); }); }
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); }
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")); }
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); }
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); }
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(); }
public void EmitLog(LogEntry log) { WriteEventLog(m_LogName, log.SerializationWithoutException(), EventLogEntryType.Error); }