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

C# LogCategory类代码示例

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

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



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


示例16: Log

        public void Log(string msg, LogPriority priority, LogCategory category)
        {
            string padding = "------";

              Console.WriteLine(padding);

              Console.WriteLine(category.ToString());
              Console.WriteLine(priority.ToString());
              Console.WriteLine(msg);

              Console.WriteLine(padding);
        }
开发者ID:bill-mybiz,项目名称:NeroUtils,代码行数:12,代码来源:ConsoleLogger.cs


示例17: WriteLine

        /// <summary>
        /// Write a trace line with message and category.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="category">The category.</param>
        public static void WriteLine(string message, LogCategory category) {
#if DEBUG
            try {
                System.Diagnostics.Trace.WriteLine(message, category.GetDescription());
            } catch (StackOverflowException ex) {
                Console.WriteLine(ex);
            }
#else            
            if(category != LogCategory.Debug)
                System.Diagnostics.Trace.WriteLine(message, category.GetDescription());
#endif
        }
开发者ID:Kacetsu,项目名称:NidhoggStudio,代码行数:17,代码来源:Trace.cs


示例18: GetSubCategory

 public List<LogCategory> GetSubCategory(int fatherid)
 {
     DataTable categorytable = dal.GetSubCategory(fatherid);
     List<LogCategory> model = new List<LogCategory>();
     foreach (DataRow item in categorytable.Rows)
     {
         LogCategory mo = new LogCategory();
         mo.CategoryID = int.Parse(item["CategoryID"].ToString());
         mo.CategoryName = item["CategoryName"].ToString();
         model.Add(mo);
     }
     return model;
 }
开发者ID:BlogPark,项目名称:BlogParkTest,代码行数:13,代码来源:CategoryOperateBLL.cs


示例19: Log

        public void Log(string message, LogCategory category, LogPriority priority)
        {
            Message = message;
            Category = category;
            Priority = priority;

            var trace = new StackTrace();
            StackFrame frame = trace.GetFrame(1);
            MethodBase method = frame.GetMethod();

            Logger.Log(LogLevel.Info, method.DeclaringType + ": " + message);

            _aggregator.GetEvent<LogEvent>().Publish(new NLogService { Message = Message, Category = Category, Priority = Priority });
        }
开发者ID:Batov,项目名称:SIDE,代码行数:14,代码来源:NLogService.cs


示例20: Log

        /// <summary>Logs the specified level.</summary>
        /// <param name="level">The logging level.</param>
        /// <param name="category">The category.</param>
        /// <param name="formatMessage">The format message.</param>
        /// <param name="args">The parameters used when format message.</param>
        public static void Log(TrinityLogLevel level, LogCategory category, string formatMessage, params object[] args)
        {
            if (string.IsNullOrEmpty(prefix))
                prefix = string.Format("[Trinity {0}]", Trinity.Instance.Version);

            if (category == LogCategory.UserInformation || level >= TrinityLogLevel.Error || (Trinity.Settings != null && Trinity.Settings.Advanced.LogCategories.HasFlag(category)))
            {
                string msg = string.Format(prefix + "{0} {1}", category != LogCategory.UserInformation ? "[" + category.ToString() + "]" : string.Empty, formatMessage);

                try
                {
                if (args.Length > 0)
                    msg = string.Format(msg, args);
                }
                catch
                {
                    msg = msg + " || " + args;
                }
                var key = new Tuple<LogCategory, TrinityLogLevel>(category, level);

                if (!LastLogMessages.ContainsKey(key))
                    LastLogMessages.Add(key, "");

                var allowDuplicates = Trinity.Settings != null && Trinity.Settings.Advanced != null && Trinity.Settings.Advanced.AllowDuplicateMessages;

                string lastMessage;
                if (LastLogMessages.TryGetValue(key, out lastMessage) && (allowDuplicates || lastMessage != msg))
                {
                    LastLogMessages[key] = msg;

                    switch (level)
                    {
                        case TrinityLogLevel.Error:
                            _Logger.Error(msg);
                            break;
                        case TrinityLogLevel.Info:
                            _Logger.Info(msg);
                            break;
                        case TrinityLogLevel.Verbose:
                            _Logger.Debug(msg);
                            break;
                        case TrinityLogLevel.Debug:
                            LogToTrinityDebug(msg);
                            break;
                    }
                }
            }
        }
开发者ID:mythsya,项目名称:db-plugins,代码行数:53,代码来源:Logger.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LogData类代码示例发布时间:2022-05-24
下一篇:
C# LogAggregator类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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