예제 #1
0
        /// <summary>
        /// 打印日志
        /// </summary>
        public virtual void PrintLog()
        {
            List <LogLevel> levels = EnumHelper.AsArray <LogLevel>()
                                     .Where(it => it != LogLevel.None)
                                     .ToList();
            var eventId = 1;

            levels.ForEach(level => _logger.Log(level, eventId++, "这是一条 {0} 日志信息.", level));
        }
예제 #2
0
        public override void PrintLog()
        {
            List <LogLevel> levels = EnumHelper.AsArray <LogLevel>()
                                     .Where(it => it != LogLevel.None)
                                     .ToList();

            using (_logger.BeginScope("ScopeId: {scopeId}", Guid.NewGuid()))
            {
                var eventId = 1;
                levels.ForEach(level => _logger.Log(level, eventId++, "这是一条 {0} 日志信息.", level));
            }

            /**
             * 需要在配置中将IncludeScopes设为true
             * 日志打印时会输出我们定义的标识信息
             * 标识一般会使用Http请求Id或者SessionId或者事务标识等
             */
        }