예제 #1
0
        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="logContent">日志内容</param>
        /// <param name="logType">日志类型</param>
        public static void WriteSysLog(string logContent, EnumType.LogType logType)
        {
            string userName = null;

            try
            {
                userName = Base_UserBusiness.GetCurrentUser().UserName;
            }
            catch
            {
            }
            Base_SysLog newLog = new Base_SysLog
            {
                Id         = Guid.NewGuid().ToSequentialGuid(),
                LogType    = logType.ToString(),
                LogContent = logContent.Replace("\r\n", "<br />").Replace("  ", "&nbsp;&nbsp;"),
                OpTime     = DateTime.Now,
                OpUserName = userName
            };

            Task.Run(() =>
            {
                try
                {
                    LoggerFactory.GetLogger().WriteSysLog(newLog);
                }
                catch
                {
                }
            });
        }
예제 #2
0
        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="logContent">日志内容</param>
        /// <param name="logType">日志类型</param>
        public void WriteSysLog(string logContent, EnumType.LogType logType, string data = null)
        {
            string userName = null;

            try
            {
                userName = Operator.Property.RealName;
            }
            catch
            {
            }
            Base_SysLog newLog = new Base_SysLog
            {
                Id         = IdHelper.GetId(),
                LogType    = logType.ToString(),
                LogContent = logContent.Replace("\r\n", "<br />").Replace("  ", "&nbsp;&nbsp;"),
                OpTime     = DateTime.Now,
                OpUserName = userName,
                Data       = data
            };

            Task.Run(() =>
            {
                try
                {
                    LoggerFactory.GetLogger().WriteSysLog(newLog);
                }
                catch
                {
                }
            });
        }
예제 #3
0
        protected Base_SysLog GetBase_SysLogInfo(LogEventInfo logEventInfo)
        {
            string id = string.Empty;

            try
            {
                id = IdHelper.GetId();
            }
            catch
            {
            }
            if (id.IsNullOrEmpty())
            {
                id = Guid.NewGuid().ToString();
            }

            Base_SysLog newLog = new Base_SysLog
            {
                Id         = id,
                Data       = logEventInfo.Properties[LoggerConfig.Data] as string,
                Level      = logEventInfo.Level.ToString(),
                LogContent = logEventInfo.Message,
                LogType    = logEventInfo.Properties[LoggerConfig.LogType] as string,
                OpTime     = logEventInfo.TimeStamp,
                OpUserName = logEventInfo.Properties[LoggerConfig.OpUserName] as string
            };

            return(newLog);
        }
예제 #4
0
        private void WriteLogUsu(object obSysLog)
        {
            Base_SysLog VSysLog = (Base_SysLog)obSysLog;

            //保存的方法
            Base_SysLogDal.Insert(VSysLog);
        }
예제 #5
0
파일: SqlLog.cs 프로젝트: lxshwyan/Lucky
        protected override void OnWrite(LogLevel level, string message)
        {
            Base_SysLog base_SysLog = new Base_SysLog()
            {
                LogContent    = message,
                LogCreateTime = DateTime.Now.ToString(),
                LogOrigin     = "System",
                LogType       = level.ToString()
            };

            repository.Insert(base_SysLog);
        }
예제 #6
0
        protected override void OnWrite(LogLevel level, string message)
        {
            Base_SysLog base_SysLog = new Base_SysLog()
            {
                LogContent    = message,
                LogCreateTime = DateTime.Now.ToString(),
                LogOrigin     = "System",
                LogType       = level.ToString()
            };

            bus.Publish(base_SysLog, "RabbitMQ.Log");
        }
예제 #7
0
        protected Base_SysLog GetBase_SysLogInfo(LogEventInfo logEventInfo)
        {
            Base_SysLog newLog = new Base_SysLog
            {
                Id         = IdHelper.GetId(),
                Data       = logEventInfo.Properties[LoggerConfig.Data] as string,
                Level      = logEventInfo.Level.ToString(),
                LogContent = logEventInfo.Message,
                LogType    = logEventInfo.Properties[LoggerConfig.LogType] as string,
                OpTime     = logEventInfo.TimeStamp,
                OpUserName = logEventInfo.Properties[LoggerConfig.OpUserName] as string
            };

            return(newLog);
        }
예제 #8
0
 public void WriteSysLog(Base_SysLog log)
 {
     _db.Insert(log);
 }
예제 #9
0
 public void WriteSysLog(Base_SysLog log)
 {
     GetElasticClient().IndexDocument(log);
 }