• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Core.Level类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中log4net.Core.Level的典型用法代码示例。如果您正苦于以下问题:C# Level类的具体用法?C# Level怎么用?C# Level使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Level类属于log4net.Core命名空间,在下文中一共展示了Level类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LogMsg

        public void LogMsg(Level level, string message)
        {
            //Debug.WriteLine( String.Format( "{0} {1}", level.ToString(), message ) );

            if (level == Level.Info)
            {
                _log.Info(message);
            }
            else if (level == Level.Debug)
            {
                _log.Debug(message);
            }
            else if (level == Level.Error)
            {
                _log.Error(message);
            }
            else if (level == Level.Warn)
            {
                _log.Warn(message);
            }
            else
            {
                _log.Info(message);
            }
        }
开发者ID:jagdishRangaswamy,项目名称:cloudera-connector,代码行数:25,代码来源:SimpleLogger.cs


示例2: Lookup

 /// <summary>
 /// Lookup the mapping for the specified level
 /// </summary>
 /// <param name="level">the level to lookup</param>
 /// <returns>the <see cref="LevelMappingEntry"/> for the level or <c>null</c> if no mapping found</returns>
 /// <remarks>
 /// <para>
 /// Lookup the value for the specified level. Finds the nearest
 /// mapping value for the level that is equal to or less than the
 /// <paramref name="level"/> specified.
 /// </para>
 /// <para>
 /// If no mapping could be found then <c>null</c> is returned.
 /// </para>
 /// </remarks>
 public LevelMappingEntry Lookup(Level level) {
   if (m_entries != null)
     foreach (LevelMappingEntry entry in m_entries)
       if (level >= entry.Level)
         return entry;
   return null;
 }
开发者ID:pesaply,项目名称:sharp-sms,代码行数:22,代码来源:LevelMapping.cs


示例3: GetIndexForLevel

 static int GetIndexForLevel(Level level)
 {
   if (level == Level.Info) return 2;
   if (level == Level.Warn) return 3;
   if (level == Level.Error || level == Level.Fatal) return 4;
   return 1;
 }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:7,代码来源:ColoredRichTextBoxAppender.cs


示例4: BindConsole

		public static void BindConsole(PatternLayout layout = null, Level level = null)
		{
			layout = layout ?? new PatternLayout
			{
				ConversionPattern = "%date{ISO8601} %level %logger - %message%newline"
			};

			layout.ActivateOptions();

			var consoleAppender = new ConsoleAppender
			{
				Name = "console",
				Layout = layout
			};

			consoleAppender.ActivateOptions();

			var hierarchy = (Hierarchy)LogManager.GetRepository();

			if (hierarchy.Root.GetAppender("console") != null)
			{
				return;
			}

			hierarchy.Root.AddAppender(consoleAppender);
			hierarchy.Root.Level = level ?? Level.Info;

			hierarchy.Configured = true;
		}
开发者ID:seyyedi,项目名称:core,代码行数:29,代码来源:LogExtensions.cs


示例5: ConvertLevelToPriority

 /// <summary>
 /// Helper method to convert <see cref="Level"/> into a string ID that is mapped based upon the TOPS Syslog standard: https://confluence.mw.inc/display/TO/TOps+Syslog+Standard
 /// </summary>
 /// <param name="level"><see cref="Level"/> to convert to string</param>
 /// <returns>string representing the syslog priority code as defined in the TOPS Syslog standard</returns>
 public static string ConvertLevelToPriority(Level level)
 {
     if (level >= Level.Emergency)
     {
         return "128";
     }
     else if (level >= Level.Fatal)
     {
         return "130";
     }
     else if (level >= Level.Error)
     {
         return "131";
     }
     else if (level >= Level.Warn)
     {
         return "132";
     }
     else if (level >= Level.Info)
     {
         return "134";
     }
     else
     {
         return "135"; // debug
     }
 }
开发者ID:JackFong,项目名称:syslog4net,代码行数:32,代码来源:PriorityConverter.cs


示例6: Log

 private static void Log(string message, Level logLevel, string exceptionMessage, params object[] parameters)
 {
     if (WriteAsync)
     {
         BackgroundWorker worker = new BackgroundWorker();
         worker.DoWork += LogEvent;
         worker.RunWorkerAsync(new LogMessageSpec
         {
             ExceptionMessage = exceptionMessage,
             LogLevel = logLevel,
             Message = message,
             Parameters = parameters,
             Stack = new StackTrace(),
             LogTime = DateTime.Now
         });
     }
     else
     {
         PerformLog(new LogMessageSpec
         {
             ExceptionMessage = exceptionMessage,
             LogLevel = logLevel,
             Message = message,
             Parameters = parameters,
             Stack = new StackTrace(),
             LogTime = DateTime.Now
         });
     }
 }
开发者ID:Theeranit,项目名称:DealMarker,代码行数:29,代码来源:LoggingHelper.cs


示例7: PerformLog

        private void PerformLog(Type type, Level level, Func<string> messageDelegate, Exception ex)
        {
            ThreadContext.Properties["subscriber"] = _subscriber.Email;
            ThreadContext.Properties["subscriberId"] = _subscriber.Id;

            _log.Logger.Log(type, level, messageDelegate.Invoke(), ex);
        }
开发者ID:RabidDog,项目名称:myfinfriend,代码行数:7,代码来源:Log4NetLogger.cs


示例8: Setup

        /// <summary>
        /// Configures the log4net environment
        /// </summary>
        private void Setup(Level logLevel)
        {
            Directory.CreateDirectory(_logFolder);


            var hierarchy = (Hierarchy)LogManager.GetRepository();

            // Log to a file
            var roller = new RollingFileAppender();
            roller.AppendToFile = false;
            roller.File = _logFile;
            roller.Layout = new PatternLayout("%date %type.%method [%-5level] - %message%newline");
            roller.MaxSizeRollBackups = 5;
            roller.RollingStyle = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            // Log to the visual studio console
            var appender = new TraceAppender();
            appender.ActivateOptions();
            appender.Layout = new PatternLayout("%method (%line) %date [%-5level] - %message%newline");
            hierarchy.Root.AddAppender(appender);

            hierarchy.Root.Level = logLevel;
            hierarchy.Configured = true;
        }
开发者ID:ElderByte-,项目名称:Archimedes.Locco,代码行数:30,代码来源:LoggerConfiguration.cs


示例9: InfoFormat

        public void InfoFormat(string format, IMessage message, MessageId messageId, int messageSize, IList<Peer> peers, Level logLevel = null)
        {
            if (peers.Count == 0)
            {
                InfoFormat(format, message, messageId, messageSize);
                return;
            }
            if (peers.Count == 1)
            {
                InfoFormat(format, message, messageId, messageSize, peerId: peers[0].Id);
                return;
            }

            var logInfo = GetLogInfo(message);
            if (!logInfo.Logger.IsInfoEnabled)
                return;

            var messageText = logInfo.GetMessageText(message);
            var otherPeersCount = peers.Count - 1;
            var peerIdText = otherPeersCount > 1
                ? peers[0].Id + " and " + otherPeersCount + " other peers"
                : peers[0].Id + " and " + otherPeersCount + " other peer";

            _logger.Logger.Log(_loggerType, logLevel ?? Level.Info, string.Format(format, messageText, messageId, messageSize, peerIdText), null);
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:25,代码来源:BusMessageLogger.cs


示例10: FromLog4Net

 internal static LogLevel FromLog4Net( Level level )
 {
     if ( level == Level.Error )
     {
         return LogLevel.Error;
     }
     else if ( level == Level.Warn )
     {
         return LogLevel.Warning;
     }
     else if ( level == Level.Notice )
     {
         return LogLevel.Notice;
     }
     else if ( level == Level.Info )
     {
         return LogLevel.Info;
     }
     else if ( level == Level.Debug )
     {
         return LogLevel.Debug;
     }
     else
     {
         throw new NotSupportedException( "LogLevel not supported: " + level );
     }
 }
开发者ID:bg0jr,项目名称:Maui,代码行数:27,代码来源:LogLevelConverter.cs


示例11: ConfigureColoredConsoleAppender

        private static void ConfigureColoredConsoleAppender(Level threshold)
        {
            var appender = new ColoredConsoleAppender
                           {
                Threshold = threshold
            };

            appender.AddMapping(
                new ColoredConsoleAppender.LevelColors
                {
                    Level = Level.Debug,
                    ForeColor = ColoredConsoleAppender.Colors.White
                });
            appender.AddMapping(
                new ColoredConsoleAppender.LevelColors
                {
                    Level = Level.Info,
                    ForeColor = ColoredConsoleAppender.Colors.Green
                });
            appender.AddMapping(
                new ColoredConsoleAppender.LevelColors
                {
                    Level = Level.Warn,
                    ForeColor = ColoredConsoleAppender.Colors.Yellow | ColoredConsoleAppender.Colors.HighIntensity
                });
            appender.AddMapping(
                new ColoredConsoleAppender.LevelColors
                {
                    Level = Level.Error,
                    ForeColor = ColoredConsoleAppender.Colors.Red | ColoredConsoleAppender.Colors.HighIntensity
                });

            ConfigureAppender(appender);
        }
开发者ID:johannesg,项目名称:NServiceBus,代码行数:34,代码来源:ConfigureInternalLog4Net.cs


示例12: LevelEvaluator

        /// <summary>
        /// Create a new evaluator using the specified <see cref="Level"/> threshold.
        /// </summary>
        /// <param name="threshold">the threshold to trigger at</param>
        /// <remarks>
        /// <para>
        /// Create a new evaluator using the specified <see cref="Level"/> threshold.
        /// </para>
        /// <para>
        /// This evaluator will trigger if the level of the event
        /// passed to <see cref="IsTriggeringEvent(LoggingEvent)"/>
        /// is equal to or greater than the <see cref="Threshold"/>
        /// level.
        /// </para>
        /// </remarks>
        public LevelEvaluator(Level threshold)
        {
            if (threshold == null)
                throw new ArgumentNullException("threshold");

            m_threshold = threshold;
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:22,代码来源:LevelEvaluator.cs


示例13: TextWriterToLog4Net

 public TextWriterToLog4Net(string loggerName, Level defaultLevel)
     : base()
 {
     this.LoggerName = loggerName;
     this.DefaultLevel = defaultLevel;
     this.TrimHeaders = true;
 }
开发者ID:masroore,项目名称:db4o-extras,代码行数:7,代码来源:TextWriterToLog4Net.cs


示例14: WriteMessage

        public static void WriteMessage(string message, Level level)
        {
            var stackTrace = new StackTrace(true);
            var frame = stackTrace.GetFrame(1);

            if (level == Level.Debug && Logger.IsDebugEnabled)
            {
                Logger.Debug(LoggerMessage.CreateMessage(message, frame));
            }
            if (level == Level.Error && Logger.IsErrorEnabled)
            {
                Logger.Error(LoggerMessage.CreateMessage(message, frame));
            }
            if (level == Level.Fatal && Logger.IsFatalEnabled)
            {
                Logger.Fatal(LoggerMessage.CreateMessage(message, frame));
            }
            if (level == Level.Warn && Logger.IsWarnEnabled)
            {
                Logger.Warn(LoggerMessage.CreateMessage(message, frame));
            }
            if (level == Level.Info && Logger.IsInfoEnabled)
            {
                Logger.Info(LoggerMessage.CreateMessage(message, frame));
            }
        }
开发者ID:kindohm,项目名称:getstem-kinect-3d,代码行数:26,代码来源:LogWriterWrapper.cs


示例15: LogControl

        public LogControl()
        {
            InitializeComponent();


            this.SuspendLayout();
            var levels = new Level[] { Level.Debug, Level.Info, Level.Warn, Level.Error, Level.Fatal };
            chkLevels = new List<CheckBox>(levels.Length);
            foreach (var level in levels)
            {
                var chkLevel = new CheckBox();
                chkLevel.Checked = level != Level.Debug;
                chkLevel.Text = level.ToString();
                chkLevel.Tag = level;
                chkLevel.CheckedChanged += new EventHandler(chkLevel_CheckedChanged);
                pnlFilter.Controls.Add(chkLevel);
                chkLevels.Add(chkLevel);
            }
            btnClean = new Button();
            btnClean.Margin = chkLevels.First().Margin;
            btnClean.Text = "clean";
            btnClean.Click += new EventHandler(btnClean_Click);
            pnlFilter.Controls.Add(btnClean);

            lblCount = new Label();
            lblCount.Margin = chkLevels.First().Margin;
            lblCount.Text = "0";
            pnlFilter.Controls.Add(lblCount);
            this.ResumeLayout(true);
        }
开发者ID:ikutsin,项目名称:BinaryAnalysis.Core,代码行数:30,代码来源:LogControl.cs


示例16: Map

 public virtual long Map(Level log4NetLevel)
 {
     if (log4NetLevel == null) return (long)LocalSyslogAppender.SyslogSeverity.Debug;
     var mappedValue = (long)LocalSyslogAppender.SyslogSeverity.Debug;
     levelMappings.TryGetValue(log4NetLevel.Name, out mappedValue);
     return mappedValue;
 }
开发者ID:JohnBloom,项目名称:rabbitmq.log4net.gelf.appender,代码行数:7,代码来源:GelfLogLevelMapper.cs


示例17: LoggerConfiguration

        public LoggerConfiguration(string appDataFolder, Level logLevel)
        {
            _logFolder = appDataFolder + "\\Logs";
            _logFile = _logFolder + "\\events.log";

            Setup(logLevel);
        }
开发者ID:ElderByte-,项目名称:Archimedes.Locco,代码行数:7,代码来源:LoggerConfiguration.cs


示例18: SetThresholdForAppender

        public static void SetThresholdForAppender(string appenderName, Level threshold)
        {
            var appender = (AppenderSkeleton) GetAppender(appenderName);

            appender.Threshold = threshold;
            appender.ActivateOptions();
            return;
        }
开发者ID:gitrab,项目名称:ssh-tunnel-manager,代码行数:8,代码来源:Logger.cs


示例19: SetUpLog

 private void SetUpLog(Level level)
 {
     _memoryAppender = new MemoryAppender();
     Logger root = ((Hierarchy) LogManager.GetRepository()).Root;
     root.Level = level;
     root.AddAppender(_memoryAppender);
     root.Repository.Configured = true;
 }
开发者ID:SvyatSlav,项目名称:MiniProfiler.Log4Net,代码行数:8,代码来源:CommonTests.cs


示例20: MethodLogger

 public MethodLogger(string text, string methodName, ILog logger, Level logLevel)
 {
     _text = text;
     _methodName = methodName;
     _logger = logger;
     _logLevel = logLevel;
     _logger.Logger.Log(typeof (MethodLogger), _logLevel, $"Entered method {_methodName}: {_text}", null);
     _stopWatch = Stopwatch.StartNew();
 }
开发者ID:RF77,项目名称:sharp-tsdb,代码行数:9,代码来源:MethodLogger.cs



注:本文中的log4net.Core.Level类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Core.LoggingEvent类代码示例发布时间:2022-05-26
下一篇:
C# Appender.RollingFileAppender类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap