当前位置: 首页>>代码示例>>C#>>正文


C# LogCategory类代码示例

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


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

示例1: Log

		///<summary>
		/// Logs the message to the configured loLog4Netgger with the 
		/// appropriate <see cref="LogCategory"/>
		///</summary>
		///<param name="message"></param>
		///<param name="logCategory"></param>
		public void Log(string message, LogCategory logCategory)
		{
			if (!IsLogging(logCategory)) return;
			switch (logCategory)
			{
				case LogCategory.Fatal:
					_log.Fatal(message);
					break;
				case LogCategory.Exception:
					_log.Error(message);
					break;
				case LogCategory.Debug:
					_log.Debug(message);
					break;
				case LogCategory.Warn:
					_log.Warn(message);
					break;
                case LogCategory.Error:
                    _log.Error(message);
                    break;
				default:
					_log.Info(message);
					break;
			}
		}
开发者ID:kevinbosman,项目名称:habanero,代码行数:31,代码来源:Log4NetLogger.cs

示例2: Log

 public void Log(LogCategory category, string text, params object[] parameters)
 {
     if ((EnabledCategories & category) != 0)
     {
         Stream.WriteLine(text, parameters);
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:FileLogProvider.cs

示例3: LogException

        /// <summary>
        /// This method is used to Log any message in the Application.
        /// </summary>
        /// <param name="eventId">Id of the event. Based on which the message will be retrieved from resource file.</param>
        /// <param name="ex">Exception object that needs to be logged in.</param>
        /// <param name="message">Some extra information / message that user will like to log.</param>
        /// <param name="category">A category which will determine where the message will get logged.</param>
        /// <param name="severity">Severity of the message. (Information / Warning / Error)</param>
        public static void LogException(int eventId, Exception ex, string message, LogCategory category, TraceEventType severity)
        {
            try
            {
                var categories = new List<LogCategory> { category };

                var extendedInformation = new Dictionary<string, object> { { "Exception", ex } };

                if (string.IsNullOrEmpty(message))
                {
                    message = ex.Message + " - Stack Trace : " + ex.StackTrace;
                }
                else
                {
                    message = message + " - " + ex.Message + " - Stack Trace : " + ex.StackTrace;
                    if (message.Length > MAX_EVENTLOG_STRING_LENGTH)
                        message = message.Substring(0, MAX_EVENTLOG_STRING_LENGTH);
                }

                WriteLogEntry(eventId, message, categories, severity, extendedInformation);
            }
            catch (Exception)
            {
            }
        }
开发者ID:agamya,项目名称:GameOfLife,代码行数:33,代码来源:ApplicationLogger.cs

示例4: LogEntry

 /// <summary>
 /// Initializes a new instance of the <see cref="LogEntry"/> class by specifying the category and the detailed information to write.
 /// </summary>
 /// <param name="category">
 /// The log category of this instance.
 /// </param>
 /// <param name="data">
 /// The data containing the detailed information to write to log.
 /// </param>
 public LogEntry(LogCategory category, object data)
 {
     Id = Guid.NewGuid();
     Category = category;
     Created = DateTime.Now;
     Data = data;
 }
开发者ID:weikaishio,项目名称:Clover.Proxy,代码行数:16,代码来源:LogEntry.cs

示例5: Log

 public void Log(string message, LogCategory logCategory)
 {
     if (!IsLogging(logCategory)) return;
     Console.Out.WriteLine("{0} {1} {2} {3} {4}", DateTime.Now.ToShortDateString(),
                           DateTime.Now.ToShortTimeString(), _contextName,
                           Enum.GetName(typeof (LogCategory), logCategory), message);
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:7,代码来源:ConsoleLoggerFactory.cs

示例6: SetTraceLevel

 public static void SetTraceLevel(LogCategory category, SourceLevels sourceLevel)
 {
     var sourceSwitch = new SourceSwitch(string.Format(CultureInfo.InvariantCulture, "MigSharp.{0}.Switch", category))
     {
         Level = sourceLevel
     };
     Sources[category].Switch = sourceSwitch;
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:8,代码来源:Log.cs

示例7: Log

 /// <summary>
 /// Writes a log entry via the logger from <see cref="Logger.Current" />.
 /// </summary>
 /// <param name="msg">The message to write.</param>
 /// <param name="category">The category.</param>
 /// <param name="prio">The priority.</param>
 /// <param name="tag">The optional tag.</param>
 /// <returns>Message was written or not.</returns>
 public static bool Log(object msg,
                        LogCategory category = LogCategory.Info, LogPriority prio = LogPriority.None,
                        string tag = null)
 {
     return Current.Log(msg: msg,
                        category: category, prio: prio,
                        tag: tag);
 }
开发者ID:mkloubert,项目名称:Diagnostics.NET,代码行数:16,代码来源:Logger.cs

示例8: Log

 public static void Log(this IEnumerable<Logging.ILog> logs, LogCategory category, string message)
 {
     if (null == logs)
         return;
     foreach (var l in logs)
         if(null != l)
             l.Log(category, message);
 }
开发者ID:BarbaraHarris,项目名称:xcricap-validator,代码行数:8,代码来源:IEnumerableILogExtensionMethods.cs

示例9: Log

 public override void Log(LogCategory category, string message)
 {
     if (this.Stack.Count == 0)
         return;
     var ts = this.Stack.Peek();
     if(null != ts)
         ts.Log(category, message);
 }
开发者ID:BarbaraHarris,项目名称:xcricap-validator,代码行数:8,代码来源:TimedLog.cs

示例10: Log

 public override void Log(LogCategory category, string message)
 {
     System.Diagnostics.Debug.WriteLine
         (
         "{0}ms\t{1}",
         this.Elapsed.TotalMilliseconds,
         message
         );
 }
开发者ID:BarbaraHarris,项目名称:xcricap-validator,代码行数:9,代码来源:TimedLogToDebug.cs

示例11: LogEntryAsync

        public static void LogEntryAsync(string message, LogSeverity logSeverity, LogCategory logCategory)
        {
            Task.Factory.StartNew(() => Logger.Write(new LogEntry
            {
	            Title = logCategory.ToString(),
	            Message = message,
	            Categories = new List<string> { logCategory.ToString() },
	            Severity = GetSeverity(logSeverity)
            }));
        }
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:10,代码来源:LogEntryData.cs

示例12: LogAsync

        /// <summary>
        /// Async operation of <see cref="LoggerBase.Log(object, LogCategory, LogPriority, string)" /> method.
        /// </summary>
        /// <param name="msg">The message.</param>
        /// <param name="category">The category.</param>
        /// <param name="prio">The priority.</param>
        /// <param name="tag">The tag.</param>
        /// <returns>The started task.</returns>
        public Task<bool> LogAsync(object msg,
                                   LogCategory category = LogCategory.Info, LogPriority prio = LogPriority.None,
                                   string tag = null)
        {
            var logMsg = CreateMessage(msg: msg,
                                       category: category, prio: prio,
                                       tag: tag);

            return LogAsync(logMsg: logMsg);
        }
开发者ID:mkloubert,项目名称:Diagnostics.NET,代码行数:18,代码来源:AsyncLogger.cs

示例13: LogEntry

 public static void LogEntry(string message, LogSeverity logSeverity, LogCategory logCategory)
 {
     Logger.Write(new LogEntry
     {
         Title = logCategory.ToString(),
         Message = message,
         Categories = new List<string> { logCategory.ToString() },
         Severity = GetSeverity(logSeverity)
     });
 }
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:10,代码来源:LogEntryData.cs

示例14: Create

 public static LogMessage Create(LogCategory logCategory, LogSeverity logSeverity, string description)
 {
     return new LogMessage
         {
             Category = logCategory,
             Severity = logSeverity,
             Description = description,
             CreatedBy = "System",
             CreatedDate = DateTime.Now
         };
 }
开发者ID:josh28,项目名称:risen,代码行数:11,代码来源:LogMessage.cs

示例15: Trace

        //[Conditional("TRACE")]
        public static void Trace(LogCategory category, string message, params object[] args)
        {
            //Queue.Queue(delegate
            //{
                ThreadContext.Properties["Category"] = category;
                string messageToLog = string.Format(message, args);

                ConsoleLog(ConsoleColor.Gray, message, args);
                _logger.Logger.Log(typeof(Log), TRACELevelTRACE, messageToLog, null);
            //});
        }
开发者ID:sharinganthief,项目名称:MoviePicker,代码行数:12,代码来源:Log.cs


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