當前位置: 首頁>>代碼示例>>C#>>正文


C# Core.Level類代碼示例

本文整理匯總了C#中log4net.Core.Level的典型用法代碼示例。如果您正苦於以下問題:C# Level類的具體用法?C# Level怎麽用?C# Level使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Level類屬於log4net.Core命名空間,在下文中一共展示了Level類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的log4net.Core.Level類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。