Esempio n. 1
0
        private void WriteToLog(Level level, string message, Exception exception)
        {
            try
            {
                if (level == Level.Critical)
                {
                    log4net.ThreadContext.Properties["EventID"] = 1;
                }
                else if (level == Level.Error)
                {
                    log4net.ThreadContext.Properties["EventID"] = 2;
                }
                else if (level == Level.Warn)
                {
                    log4net.ThreadContext.Properties["EventID"] = 3;
                }
                else if (level == Level.Trace)
                {
                    log4net.ThreadContext.Properties["EventID"] = 4;
                }
                else if (level == Level.Info)
                {
                    log4net.ThreadContext.Properties["EventID"] = 5;
                }

                _logger.Log(ThisDeclaringType, level, message, exception);
            }
            catch { }
        }
Esempio n. 2
0
        public void Log(LogLevel level, Exception exception, string message, object[] args)
        {
            var logLevel = ConvertLevel(level);

            if (message == null && exception != null)
            {
                message = exception.Message;
            }

            object messageObj = message;

            if (args != null && args.Length > 0)
            {
                messageObj = new SystemStringFormat(CultureInfo.CurrentUICulture, message, args);
            }

            var loggingEvent = new LoggingEvent(
                _declaringType,
                _logger.Repository,
                _logger.Name,
                logLevel,
                messageObj,
                exception);

            loggingEvent.Properties["LevelId"] = (int)level;
            TryAddExtendedThreadInfo(loggingEvent);

            _logger.Log(loggingEvent);
        }
Esempio n. 3
0
        /// <summary>
        ///     获取日志输出处理委托实例
        /// </summary>
        /// <param name="level">日志输出级别</param>
        /// <param name="message">日志消息</param>
        /// <param name="exception">日志异常</param>
        /// <param name="isData">是否数据日志</param>
        protected override void Write(LogLevel level, object message, Exception exception, bool isData = false)
        {
            if (isData)
            {
                return;
            }
            Level log4NetLevel = GetLevel(level);

            _logger.Log(DeclaringType, log4NetLevel, message, exception);
        }
Esempio n. 4
0
        /// <summary>
        /// 获取日志输出处理委托实例
        /// </summary>
        /// <param name="level">日志输出级别</param>
        /// <param name="message">日志消息</param>
        /// <param name="exception">日志异常</param>
        /// <param name="isData">是否数据日志</param>
        protected override void Write(LogLevel level, object message, Exception exception, bool isData = false)
        {
            if (isData)
            {
                return;
            }
            Level log4NetLevel = GetLevel(level);

            if (message.GetType() != typeof(string))
            {
                message = message.ToJsonString();
            }
            _logger.Log(DeclaringType, log4NetLevel, message, exception);
        }
Esempio n. 5
0
        protected override void WriteInternal(LogLevel level, object message, Exception exception)
        {
            string str;

            if (message == null)
            {
                str = "NULL";
            }
            else
            {
                var type = message.GetType();
                if (type.IsValueType || type == typeof(string))
                {
                    str = message.ToString();
                }
                else
                {
                    str = JsonHelper.ToJson(message);
                }
            }

            _logger.Log(typeof(Log4NetLog), ParseLevel(level), str, exception);
        }
Esempio n. 6
0
 public void Debug(String message)
 {
     if (IsDebugEnabled)
     {
         Logger.Log(ownerType, Level.Debug, message, null);
     }
 }
 public void Debug(String message)
 {
     if (IsDebugEnabled)
     {
         AddExtendedThreadInfo();
         Logger.Log(declaringType, Level.Debug, message, null);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 获取日志输出处理委托实例
        /// </summary>
        /// <param name="level">日志输出级别</param>
        /// <param name="message">日志消息</param>
        /// <param name="exception">日志异常</param>
        protected override void Write(LogLevel level, object message, Exception exception, bool isData = false)
        {
            Level level1 = GetLevel(level);

            _logger.Log(DeclaringType, level1, message, exception);
        }
Esempio n. 9
0
 public override void Log(Type source, Module.Logger.Level level, object @object, Exception exception)
 {
     _logger = _logger ?? LoggerManager.GetLogger(Assembly.GetExecutingAssembly(), Owner);
     // level - slow
     _logger.Log(Owner, new log4net.Core.Level(level.Value, level.Name), @object, exception);
 }
Esempio n. 10
0
 public void Trace(string message)
 {
     if (IsTraceEnabled)
     {
         Logger.Log(DeclaringType, Level.Trace, message, null);
     }
 }
Esempio n. 11
0
        public static void WriteLog(LogLevel level, string message)
        {
            var logLevel = GetLogLevel(level);

            logger.Log(logType, logLevel, message, null);
        }
Esempio n. 12
0
 /// <summary>
 /// 获取日志输出处理委托实例
 /// </summary>
 /// <param name="level">日志输出级别</param>
 /// <param name="message">日志消息</param>
 /// <param name="exception">日志异常</param>
 protected override void WriteInternal(LogLevel level, object message, Exception exception)
 {
     _logger.Log(DeclaringType, GetLevel(level), message, exception);
 }
Esempio n. 13
0
        public void WriteLog(LogLevel level, string message, Exception exception)
        {
            Level log4Level = LevelMap(level);

            _logger.Log(DeclaringType, log4Level, message, exception);
        }
 public void Debug(Func <object> messageFactory, Exception exception = null)
 {
     if (IsDebugEnabled)
     {
         _logger.Log(declaringType, Level.Debug, GetErrorMessage(messageFactory.Invoke()), exception);
     }
 }
Esempio n. 15
0
 protected override void WriteInternal(LogLevel level, object message, Exception exception)
 {
     _logger.Log(typeof(Log4NetLog), ParseLevel(level), Format(message, exception),
                 exception);
 }
Esempio n. 16
0
        /// <summary>
        /// 获取日志输出处理委托实例
        /// </summary>
        /// <param name="level">日志输出级别</param>
        /// <param name="message">日志消息</param>
        /// <param name="exception">日志异常</param>
        protected override void Write(LogLevel level, object message, Exception exception)
        {
            Level log4NetLevel = GetLevel(level);

            _logger.Log(DeclaringType, log4NetLevel, message, exception);
        }
Esempio n. 17
0
 /// <summary>
 /// Log to the wrapped log4net logger
 /// </summary>
 public void LogInternal(Level level, string message, Exception ex = null)
 {
     logger.Log(DeclaringType, level, message, ex);
 }