public override string ToString() { if (Type == LogTypeEnum.CUSTOM) { return(CustomName); } return(Type.ToString()); }
private string GetLogDiv(string message, LogTypeEnum logType) { return ($@" 'type': '{logType.ToString().ToLower()}', 'time': '{DateTime.Now.TimeOfDay}', 'message': '{message}' }} "); }
public LogAuditoria(string identifier, string message, string detail, LogSourceEnum source, LogTypeEnum type) { Id = Guid.NewGuid(); Identifier = identifier; Message = message; Detail = detail; Source = source.ToString(); Type = type.ToString(); Data = DateTime.Now; }
private string GetLogFileName(LogTypeEnum logType) { switch (logType) { case LogTypeEnum.SelectOne: throw new NotSupportedException("A log type must be selected."); case LogTypeEnum.Application: return(logType.ToString()); case LogTypeEnum.Security: return(logType.ToString()); case LogTypeEnum.Setup: return(logType.ToString()); case LogTypeEnum.System: return(logType.ToString()); } return(LogTypeEnum.Application.ToString()); }
public void Log(LogTypeEnum logType, string message, string properties) { string logFile = GetLogFileName(); EnsureFileExists(logFile); var el = (XmlElement)_LogXml.DocumentElement.AppendChild(_LogXml.CreateElement("log")); el.SetAttribute("datecreated", CurrentDatetime); el.SetAttribute("logType", logType.ToString()); el.AppendChild(_LogXml.CreateElement("message")).InnerText = message; el.AppendChild(_LogXml.CreateElement("properties")).InnerText = properties; _LogXml.Save(logFile); }
static string SaveLog(LogTypeEnum logTypeEnum, string logMessage) { if (HttpContext.Current.Items.Contains("GeneralLog")) { object controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"]; object action = HttpContext.Current.Request.RequestContext.RouteData.Values["action"]; GeneralLog generalLog = HttpContext.Current.Items["GeneralLog"] as GeneralLog; GeneralLog errorGeneralLog = Mapper.Map <GeneralLog, GeneralLog>(generalLog); errorGeneralLog.Id = Guid.NewGuid().ToString(); errorGeneralLog.LogType = logTypeEnum.ToString(); errorGeneralLog.RequestTraceId = generalLog.Id; errorGeneralLog.RequestAction = action == null ? "" : action.ToString(); errorGeneralLog.RequestController = controller == null ? "" : controller.ToString(); errorGeneralLog.CreateTime = errorGeneralLog.CreateTime == default(DateTime) ? DateTime.Now : errorGeneralLog.CreateTime; return(errorGeneralLog.Id); } return(null); }
protected override void Log(object logData, LogTypeEnum logType) { string path = Path.GetFullPath(this.ConfigurationUtility.LogPath); string fullPath = Path.GetFullPath(path + "WhereIsMyChangeLog.txt"); if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } if (File.Exists(fullPath) == false) { File.Create(fullPath).Dispose(); } string serializedObject = Dlp.Framework.Serializer.JsonSerialize(logData); string content = string.Format("{0} - {1} - {2}{3}", DateTime.UtcNow, logType.ToString(), serializedObject, Environment.NewLine); File.AppendAllText(fullPath, content); }
public static LogAuditoria NewLogAuditoriaFull(string identifier, string message, string detail, LogSourceEnum source, LogTypeEnum type, string user, string hostname, string url, string controller, string method, int statusCode, string cookies, string serverVariables) { var logAudit = new LogAuditoria() { Id = Guid.NewGuid(), Data = DateTime.Now, Identifier = identifier, Message = message, Detail = detail, Source = source.ToString(), Type = type.ToString(), User = user, Hostname = hostname, Url = url, Controller = controller, Method = method, StatusCode = statusCode, Cookies = cookies, ServerVariables = serverVariables }; return(logAudit); }
public Log4NetWriter(LogTypeEnum logType) { _log4Net = log4net.LogManager.GetLogger(logType.ToString()); }
/// <summary> /// 根据LogContent写日志 /// </summary> /// <param name="content"></param> public static void Log(LogContent content, LogTypeEnum logType) { Log(content.ToString(), logType.ToString()); }
/// <summary> /// 写日志 /// </summary> /// <param name="msg"></param> public static void Log(string msg, LogTypeEnum logType) { Log(msg, logType.ToString()); }
public static void Log(LogTypeEnum type, string msg) { if (!Directory.Exists(LOG_DIR)) { Directory.CreateDirectory(LOG_DIR); } File.AppendAllText(Path.Combine(LOG_DIR, LOG_NAME), DateTime.Now.ToString() + " " + type.ToString() + " " + msg + Environment.NewLine); }