private static void ReadyForWork(string message, string logType, bool isWriteTxt) { if (!AppConfig.Log.IsWriteLog) { Error.Throw("Error : " + logType + " : " + message); } SysLogs log = new SysLogs(); log.IsWriteLogOnError = false; log.IsWriteToTxt = isWriteTxt; log.Message = message; log.LogType = logType; log.CreateTime = DateTime.Now; if (AppConfig.IsWeb && System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Handler != null) { System.Web.HttpRequest request = System.Web.HttpContext.Current.Request; log.PageUrl = request.Url.Scheme + "://" + request.Url.Authority + System.Web.HttpUtility.UrlDecode(request.RawUrl); if (request.UrlReferrer != null && request.Url != request.UrlReferrer) { log.RefererUrl = System.Web.HttpUtility.UrlDecode(request.UrlReferrer.ToString()); } log.HttpMethod = request.HttpMethod; log.ClientIP = request.Headers["X-Real-IP"] ?? request.UserHostAddress; } LogWorker.Add(log); }
private static void ReadyForWork(string message, string logType, bool isWriteTxt) { if (!AppConfig.Log.IsWriteLog) { Error.Throw("Error : " + logType + " : " + message); } SysLogs log = new SysLogs(); log.IsWriteLogOnError = false; log.IsWriteToTxt = isWriteTxt; log.Message = message; log.LogType = logType; log.CreateTime = DateTime.Now; if (AppConfig.IsWeb && System.Web.HttpContext.Current != null) { System.Web.HttpRequest request = System.Web.HttpContext.Current.Request; log.PageUrl = request.Url.Scheme + "://" + request.Url.Authority + request.RawUrl; if (request.UrlReferrer != null && request.Url != request.UrlReferrer) { log.RefererUrl = request.UrlReferrer.ToString(); } } LogWorker.Add(log); }