public SOSAppException(Exception exception, string page, string ipAddress, LogSeverityEnum severity) : base(exception.Message, exception.InnerException) { PageName = page; IPAddress = ipAddress; LogSeverity = severity; }
public void Log(LogSeverityEnum severity, string msg) { if (severity >= Severity) { LogIt(severity, msg); } }
public AppException(Exception exception, string code, string ipAddress, LogSeverityEnum severity) : base(exception.Message, exception.InnerException) { Code = code; IPAddress = ipAddress; LogSeverity = severity; }
/// <summary> /// Escreve log em um arquivo. /// </summary> /// <param name="message">Mensagem para logar.</param> public void WriteLog(LogSeverityEnum severity, string message, object args = null) { string path = this.ConfigurationUtility.LogFilePath; string fileName = this.ConfigurationUtility.LogFileName; try { if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } FileStream fileStream = new FileStream(Path.Combine(path, fileName), FileMode.Append); using (StreamWriter streamWriter = new StreamWriter(fileStream)) { string serializedObject = null; if (args != null) { serializedObject = Serializer.JsonSerialize(args); } streamWriter.WriteLine(string.Format("[{0}] [{1}] {2} {3}", DateTime.Now.ToString(), severity.ToString().PadRight(15), message, serializedObject)); } } catch (Exception) { } }
protected override void aLog(LogSeverityEnum s, string cat, string msg) { this.DbInsert.Parameters[0].Value = s; this.DbInsert.Parameters[1].Value = cat; this.DbInsert.Parameters[2].Value = msg; this.DbInsert.ExecuteNonQuery(); }
public static void WriteLog(string logType, string logSource, LogSeverityEnum logSeverityEnum, string logContent, string logOperator) { if (_systemLog == false) { return; } // string hostName = String.Empty; string hostIP = String.Empty; string hostMac = String.Empty; if (string.IsNullOrEmpty(_systemArchitectureType)) { throw new Exception("系统配置项[SystemArchitectureType]配置有误,请联系管理员!"); } else if (_systemArchitectureType.ToUpper() == "CS") { hostName = System.Environment.UserDomainName + "\\" + System.Environment.MachineName; // System.Net.IPAddress[] addressList = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList; for (int i = 0; i < addressList.Length; i++) { if (addressList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { hostIP += ":" + addressList[i].ToString(); } } hostIP = hostIP.TrimStart(':'); // System.Management.ManagementClass mc = new System.Management.ManagementClass("Win32_NetworkAdapterConfiguration"); System.Management.ManagementObjectCollection moc = mc.GetInstances(); foreach (System.Management.ManagementObject mo in moc) { if (mo["IPEnabled"].ToString() == "True") { hostMac = mo["MacAddress"].ToString(); break; } } } else if (_systemArchitectureType.ToUpper() == "BS") { hostName = System.Web.HttpContext.Current.Request.UserHostName; hostIP = System.Web.HttpContext.Current.Request.UserHostAddress; } else { throw new Exception("系统配置项[SystemArchitectureType]配置有误,请联系管理员!"); } SSLogManager.WriteLog(logType, logSource, logSeverityEnum, logContent, logOperator, hostName, hostIP, hostMac); }
/// <summary> /// Escreve log em um arquivo. /// </summary> /// <param name="message">Mensagem para logar.</param> public void WriteLog(LogSeverityEnum severity, string message, object args = null) { string serializedObject = null; if (args != null) { serializedObject = Serializer.JsonSerialize(args); } message = string.Format("{0} {1}", message, serializedObject); this.ApplicationLogRepository.Insert((short)severity, message); }
public void log(LogSeverityEnum s, string cat, string msg) { try { if (aCanLog()) { aLog(s, cat, msg); } } catch (Exception ex) { System.Diagnostics.Debugger.Log(9999, this.ToString(), ex.Message); } }
/// <summary> /// Initializes a new instance of the Exception class with a specified error message. /// </summary> /// <param name="message">The message that describes the error.</param> public AppException(string message, string code, string ipAddress, LogSeverityEnum severity, string module = null) : base(message) { Code = code; IPAddress = ipAddress; LogSeverity = severity; if (module != null) { Module = module; } else { Module = string.Empty; } }
/// <summary> /// Initializes a new instance of the Exception class with a specified error message. /// </summary> /// <param name="message">The message that describes the error.</param> public SOSAppException(string message, string page, string ipAddress, LogSeverityEnum severity, string module = null) : base(message) { PageName = page; IPAddress = ipAddress; LogSeverity = severity; if (module != null) { ModuleName = module; } else { ModuleName = string.Empty; } }
/// <summary> /// Escreve log em um arquivo. /// </summary> /// <param name="message">Mensagem para logar.</param> public void WriteLog(LogSeverityEnum severity, string message, object args = null) { string serializedObject = null; if (args != null) { serializedObject = Serializer.JsonSerialize(args); } string sSource = Assembly.GetCallingAssembly().FullName; string sLog = string.Format(CultureInfo.InvariantCulture, "{0} {1}", message, serializedObject); string sEvent = severity.ToString(); if (!EventLog.SourceExists(sSource)) { EventLog.CreateEventSource(sSource, "Application"); } EventLog.WriteEntry(sSource, sLog); }
public static void WriteLog(string logType, string logSource, LogSeverityEnum logSeverityEnum, string logContent, string logOperator, string hostName, string hostIP, string hostMac) { if (_systemLog == false) { return; } // CO_SYSTEM_LOG log = new CO_SYSTEM_LOG(); log.LogGuid = Guid.NewGuid(); log.LogType = logType; log.LogSource = logSource; log.LogSeverity = Convert.ToInt32(logSeverityEnum); log.LogContent = logContent; log.LogDate = DAO.UtilDAO.GetDatabaseDatetime(); log.LogDateUtc = DAO.UtilDAO.GetDatabaseUtcDatetime(); log.LogOperator = logOperator; log.HostName = hostName; log.HostIP = hostIP; log.HostMac = hostMac; SSLogManager.WriteLog(log); }
public void log(LogSeverityEnum s, Enum cat, string msg) { log(s, cat.ToString(), msg); }
/// <summary> /// Initializes a new instance of the Exception class with a specified error message and a reference to the inner exception that is the cause of this exception. /// </summary> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param> /// <param name="page">Page of error.</param> /// <param name="ipAddress">Usuario IP Address.</param> /// <param name="severity">Error Severity.</param> public AppException(string message, Exception innerException, string page, string ipAddress, LogSeverityEnum severity) : base(message, innerException) { }
protected abstract void aLog(LogSeverityEnum s, string cat, string msg);
public new void log(LogSeverityEnum s, string cat, string msg) { System.Diagnostics.Debugger.Log(0, cat, msg); }
protected override void LogIt(LogSeverityEnum severity, string msg) { Console.WriteLine($"{System.DateTime.Now.ToString("HH:mm:ss")} | {severity.ToString()} | {msg}"); }
protected override void aLog(LogSeverityEnum s, string cat, string msg) { this.Writer.Write("[{0}]::[{1}]::[{2}]::[{3}]", new object[] { DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), s, cat, msg }); }
protected abstract void LogIt(LogSeverityEnum severity, string msg);
protected override void aLog(LogSeverityEnum s, string cat, string msg) { System.Diagnostics.Debugger.Log((int)s, cat, msg); }
public void log(LogSeverityEnum s, string cat, string msg) { this.setLogInfo(new LogInfo(s, cat, msg)); //System.Diagnostics.Debugger.Log( 0, this.ToString(), "Put on Queue\n" ); }