public DotException(LogMessage message) { if (message != null) LogMessage = message; else msg = "异常消息为空!"; }
public void Warn(LogMessage log, System.Exception ex) { if (this.IsWarnEnabled) { LoggingEvent loggingEvent = new LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Warn, log.Message, ex); SetLogMessage(loggingEvent, log); Logger.Log(loggingEvent); } }
public void WriteLogTest() { //Log.LogFactory.DataLog.Info(new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(),AreaName="area1",ControllerName="con2",ActionName="action3" }); var log = new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(), AreaName = "area1", ControllerName = "con2", ActionName = "action3", }; log.ExtendPropety.Add("ou", "testou"); Log.LogFactory.WebBusinessLog.Info(log ); Log.LogFactory.WebDataLog.Info(new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(),AreaName="area1",ControllerName="con2",ActionName="action3" }); //Log.LogFactory.RunningLog.Info(new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(),AreaName="area1",ControllerName="con2",ActionName="action3" }); Loghelper.WriteLog("today"); }
public ReferencedException(LogMessage message ) : base(message ) { }
public ConfigException(LogMessage message) : base(message) { }
public ValidationException(LogMessage message) : base(message ) { }
public ObjectExistException(LogMessage message ) : base(message ) { }
public void Error(LogMessage log) { Error(log, null); }
public void Warn(LogMessage log) { Warn(log, null); }
public void Info(LogMessage log) { Info(log, null); }
public void Debug(LogMessage log) { Debug(log, null); }
private void SetLogMessage(LoggingEvent loggingEvent, LogMessage log) { try { if (!string.IsNullOrEmpty(log.ClientIP)) { loggingEvent.Properties["ClientIP"] = log.ClientIP; } else { loggingEvent.Properties["ClientIP"] = Net.IPHelper.GetClientIp(); } } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.RequestUrl)) { loggingEvent.Properties["RequestUrl"] = log.RequestUrl; } else if (null != System.Web.HttpContext.Current) { loggingEvent.Properties["RequestUrl"] = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; } } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.ServerIP)) { loggingEvent.Properties["ServerIP"] = log.ServerIP; } else if (null != System.Web.HttpContext.Current) { loggingEvent.Properties["ServerIP"] = Net.IPHelper.GetLocalIP(); } } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.UserId)) { loggingEvent.Properties["UserId"] = log.UserId; } } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.UserName)) { loggingEvent.Properties["UserName"] = log.UserName; } else if (System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated) { loggingEvent.Properties["UserName"] = System.Threading.Thread.CurrentPrincipal.Identity.Name; } else if (!string.IsNullOrEmpty(loggingEvent.UserName)) { loggingEvent.Properties["UserName"] = loggingEvent.UserName; } } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.DisplayName)) loggingEvent.Properties["DisplayName"] = log.DisplayName; } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.AreaName)) loggingEvent.Properties["AreaName"] = log.AreaName; } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.ControllerName)) loggingEvent.Properties["ControllerName"] = log.ControllerName; } catch (Exception ex) { } try { if (!string.IsNullOrEmpty(log.ActionName)) loggingEvent.Properties["ActionName"] = log.ActionName; } catch (Exception ex) { } try { foreach (var item in log.ExtendPropety) { if (!string.IsNullOrEmpty(item.Value)) { loggingEvent.Properties[item.Key] = item.Value; } } } catch (Exception ex) { } }
public void Fatal(LogMessage log) { Fatal(log, null); }