///<summary> /// 记录信息 ///</summary> ///<param name="msg">错误提示</param> ///<param name="contextInfo">消息详细内容</param> ///<param name="logType">日志类型</param> ///<param name="errorPath">错误地址</param> public static void Log(string msg, string contextInfo, LoggerTyp logType, string errorPath) { var builder = new StringBuilder(); builder.AppendFormat("Time={0}; ", DateTime.Now); if (!string.IsNullOrEmpty(msg)) { builder.AppendLine(); builder.AppendFormat("[ErrorTitle]={0}", msg); } if (!string.IsNullOrEmpty(contextInfo)) { builder.AppendLine(); builder.AppendFormat("[ContextInfo]={0}", contextInfo); } if (!string.IsNullOrEmpty(errorPath)) { builder.AppendLine(); builder.AppendFormat("[Request Path]={0}", errorPath); } builder.AppendLine(); switch (logType) { case LoggerTyp.Info: if (LogLoginfo.IsDebugEnabled) { LogLoginfo.Info(builder.ToString()); } break; case LoggerTyp.Error: if (LogLogerror.IsDebugEnabled) { LogLogerror.Info(builder.ToString()); } break; case LoggerTyp.Debug: if (LogLogdebug.IsDebugEnabled) { LogLogdebug.Info(builder.ToString()); } break; } }
///<summary> /// 记录信息 ///</summary> ///<param name="msg">错误提示</param> ///<param name="contextInfo">消息详细内容</param> ///<param name="ex">异常</param> ///<param name="logType">日志类型</param> ///<param name="errorPath">错误地址</param> public void Log(string msg, string contextInfo, Exception ex, LoggerTyp logType, string errorPath = null) { Logger.Log(msg, contextInfo, ex, logType, errorPath); }