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

C# LoggingLevel类代码示例

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

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



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

示例1: LogException

 public void LogException(MethodBase methodBase, Exception err, LoggingLevel exceptionLevel)
 {
     ILog logger = LogManager.GetLogger(methodBase.DeclaringType);
     if (ShouldLog(logger, exceptionLevel, methodBase)) {
         exceptionLogger.LogException(err, false, methodBase.DeclaringType);
     }
 }
开发者ID:robiee4u,项目名称:Sharp-Architecture-Contrib,代码行数:7,代码来源:MethodLogger.cs


示例2: Create

        /// <summary>
        /// Parses the XML of the configuration section.
        /// </summary>
        /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
        /// <param name="configContext">An HttpConfigurationContext when Create is called from the ASP.NET configuration system. Otherwise, this parameter is reserved and is a null reference.</param>
        /// <param name="section">The XmlNode that contains the configuration information from the configuration file. Provides direct access to the XML contents of the configuration section.</param>
        /// <returns>A configuration object.</returns>
        public object Create(object parent, object configContext, XmlNode section)
        {
            XmlElement loggingElement = (XmlElement) section;
            if (loggingElement.HasAttribute("LoggingLevel"))
            {
                loggingLevel = (LoggingLevel) Enum.Parse(typeof(LoggingLevel), loggingElement.GetAttribute("LoggingLevel"), true);
            }
            else
            {
                loggingLevel = LoggingLevel.Off;
            }

            if (loggingElement.HasChildNodes)
            {
                foreach (XmlElement element in loggingElement.SelectNodes("logger"))
                {
                    string typeName = element.GetAttribute("type");

                    // Use reflection to create an instance of the configured Logger instance
                    Type type = Type.GetType(typeName);
                    LoggerBase logger = (LoggerBase) type.Assembly.CreateInstance(type.FullName);
                    logger.Configure(element);
                    loggers.Add(logger);
                }
            }

            return this;
        }
开发者ID:SolidSnake74,项目名称:SharpCore,代码行数:35,代码来源:LoggingSectionHandler.cs


示例3: LogItem

 /// <summary>
 /// Initializes a new LogItem class
 /// </summary>
 /// <param name="message">Message to log</param>
 /// <param name="exception">Exception to log</param>
 /// <param name="level">Message level</param>
 public LogItem(string message, Exception exception = null, LoggingLevel level = LoggingLevel.Info)
 {
     Message = message;
     Exception = exception;
     Created = DateTime.UtcNow;
     Level = level;
 }
开发者ID:Grinderofl,项目名称:Logger,代码行数:13,代码来源:LogItem.cs


示例4: LogEntry

        public override void LogEntry(string source, string message, LoggingLevel loggingLevel)
        {
            if (EventLog.Exists(logName))
            {
                StringWriter writer = new StringWriter();
                writer.WriteLine("Source: " + source);
                writer.WriteLine("Message: " + message);
                message = writer.ToString();

                switch (loggingLevel)
                {
                    case LoggingLevel.Error:
                        EventLog.WriteEntry(logName, message, EventLogEntryType.Error);
                        break;
                    case LoggingLevel.Warning:
                        EventLog.WriteEntry(logName, message, EventLogEntryType.Warning);
                        break;
                    case LoggingLevel.Information:
                    case LoggingLevel.Verbose:
                        EventLog.WriteEntry(logName, message, EventLogEntryType.Information);
                        break;
                    default:
                        break;
                }
            }
            else
            {
                StringWriter writer = new StringWriter();
                writer.WriteLine("Entries cannot be written to the " + logName + " log because it does not exist.");
                writer.WriteLine("Source: " + source);
                writer.WriteLine("Message: " + message);

                throw new InvalidOperationException(writer.ToString());
            }
        }
开发者ID:SolidSnake74,项目名称:SharpCore,代码行数:35,代码来源:EventLogLogger.cs


示例5: CommonServiceException

 /// <summary>
 /// Initializes a new instance of the 
 /// <see cref="T:WebApplications.Utilities.Logging.LoggingException" /> class.
 /// </summary>
 /// <param name="level">The log level.</param>
 /// <param name="resource">The resource expression, e.g. ()=&gt; Resources.Log_Message.</param>
 /// <param name="parameters">The parameters.</param>
 internal CommonServiceException(
     LoggingLevel level,
     [CanBeNull] Expression<Func<string>> resource,
     [CanBeNull] params object[] parameters)
     : base(level, resource, parameters)
 {
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:14,代码来源:CommonServiceException.cs


示例6: WriteLog

            public static void WriteLog(string messageFormat, LoggingLevel loggingLevel = LoggingLevel.Default, params object[] args) {
                //WriteLog(String.Format(message, args), loggingLevel);
#if DEBUG
                lock (lockFlag) {
#endif
                    {
                        string message = messageFormat;
                        bool isNotMessageFormatted = true;

                        try {
                            message = string.Format(messageFormat, args);
                            isNotMessageFormatted = false;
                        }
                        catch { }

                        WriteConsole(message);

                        if (IsLoggingToFileEnabled) {
                            if (message.Length < 20 * 1024) {
                                LogToFile(message);
                            }
                        }
                    }
#if DEBUG
                }
#endif
            }
开发者ID:vhnatyk,项目名称:WebMarco.2.0,代码行数:27,代码来源:Utilities.cs


示例7: DatabaseSchemaException

 /// <summary>
 /// Initializes a new instance of the <see cref="LoggingException" /> class.
 /// </summary>
 /// <param name="level">The severity of the exception being logged.</param>
 /// <param name="resource">The resource expression, e.g. ()=&gt; Resources.Log_Message.</param>
 /// <param name="parameters">The parameters.</param>
 public DatabaseSchemaException(
     LoggingLevel level,
     [CanBeNull] Expression<Func<string>> resource,
     [CanBeNull] params object[] parameters)
     : base(level, resource, parameters)
 {
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:13,代码来源:DatabaseSchemaException.cs


示例8: Log

 public static void Log(LoggingLevel level, Exception exception)
 {
     if (exception != null)
     {
         Log(level, exception.ToString());
     }
 }
开发者ID:WPT-KL,项目名称:Kongliang,代码行数:7,代码来源:Logger.cs


示例9: Log

        protected override void Log(LoggingLevel level, object sender, object message, object verbose, Exception t)
        {
            if (!(IsVerboseEnabled))
                verbose = "";

            WriteLine(level, message.ToString() + "; " + t.ToString() + "; " + verbose, sender); // do not localize
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:7,代码来源:WebTraceLogger.cs


示例10: Log

 public void Log(Exception exception, LoggingLevel loggingLevel, [CallerMemberName] string memberName = "", [CallerFilePath] string classFilePath = "", [CallerLineNumber]int line = 0)
 {
     if (exception != null)
     {
         Log(exception.Message, loggingLevel, memberName, classFilePath, line);
     }
 }
开发者ID:maliroteh,项目名称:SalesforceMobileSDK-Windows,代码行数:7,代码来源:Logger.cs


示例11: Log

 /// <summary>
 /// Log a message
 /// </summary>
 /// <param name="level"></param>
 /// <param name="function"></param>
 /// <param name="message"></param>
 /// <param name="ex"></param>
 public static void Log(LoggingLevel level, string function, string message, Exception ex)
 {
     if (level >= minLevel)
     {
         // log message to file, email, pager
     }
 }
开发者ID:jediskywalker,项目名称:RTDeals,代码行数:14,代码来源:Logging.cs


示例12: Logger

 public Logger(string path, LoggingLevel level, params TextWriter[] otherOutputs)
 {
     _path = path;
     _level = level;
     _otherOutputs = otherOutputs;
     _messageBuffer = new List<string>();
 }
开发者ID:brascoball,项目名称:sensus,代码行数:7,代码来源:Logger.cs


示例13: LogEntry

        public void LogEntry(MethodBase methodBase, object[] argumentValues, LoggingLevel entryLevel)
        {
            var logger = LogManager.GetLogger(methodBase.DeclaringType);
            if (this.ShouldLog(logger, entryLevel, methodBase))
            {
                var logMessage = new StringBuilder();
                logMessage.Append(string.Format("{0}(", methodBase.Name));

                var parameterInfos = methodBase.GetParameters();
                if (argumentValues != null && parameterInfos != null)
                {
                    for (var i = 0; i < argumentValues.Length; i++)
                    {
                        if (i > 0)
                        {
                            logMessage.Append(" ");
                        }

                        logMessage.Append(string.Format("{0}:[{1}]", parameterInfos[i].Name, argumentValues[i]));
                    }
                }

                logMessage.Append(")");
                logger.Log(entryLevel, logMessage.ToString());
            }
        }
开发者ID:barser,项目名称:Sharp-Architecture-Contrib,代码行数:26,代码来源:MethodLogger.cs


示例14: LogMessage

        private static void LogMessage(object sender, LoggingLevel loggingLevel, string message, params object[] args)
        {
            try
            {
                string loggerName = "Main";
                if (sender != null)
                {
                    loggerName = sender.GetType().Name;
                }

                message = string.Format(message, args);

                Logger logger = LogManager.GetLogger(loggerName);
                switch (loggingLevel)
                {
                    case LoggingLevel.Error: logger.Error(message); break;
                    case LoggingLevel.Warning: logger.Warn(message); break;
                    case LoggingLevel.Info: logger.Info(message); break;
                    case LoggingLevel.Critical: logger.Fatal(message); break;
                    default: logger.Debug(message); break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("NLog exception: {0}, {1}", ex.Message, ex.StackTrace));
            }
        }
开发者ID:SresgaminG,项目名称:ArmamutE,代码行数:27,代码来源:LogHelper.cs


示例15: ShouldLog

        private bool ShouldLog(ILog logger, LoggingLevel loggingLevel, MethodBase methodBase)
        {
            if (methodBase != null && methodBase.Name != null) {
                return logger.IsEnabledFor(loggingLevel);
            }

            return false;
        }
开发者ID:robiee4u,项目名称:Sharp-Architecture-Contrib,代码行数:8,代码来源:MethodLogger.cs


示例16: Log

 protected override void Log(LoggingLevel level, object sender, object message, object verbose)
 {
     if (!(IsVerboseEnabled))
         verbose = "";
     WriteLine(level,
               DateTime.Now.ToString("yyyy-dd-MM HH:mm:ss") + "; " + level.ToString() + "; " +
               sender.GetType().ToString() + "; " + message.ToString() + "; " + verbose); // do not localize
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:8,代码来源:SimpleLogger.cs


示例17: Logger

        public Logger(string path, LoggingLevel level, params TextWriter[] otherOutputs)
        {
            _path = path;
            _level = level;
            _otherOutputs = otherOutputs;

            InitializeFile(_path, true);
        }
开发者ID:trishalaneeraj,项目名称:sensus,代码行数:8,代码来源:Logger.cs


示例18: WriteLine

 public static void WriteLine(string message, LoggingLevel level)
 {
     if (Level >= level)
       {
     if (LogEntryAdded != null)
       LogEntryAdded(null, new LogEventArgs(message));
       }
 }
开发者ID:joshuabenuck,项目名称:USBSimulator,代码行数:8,代码来源:Logger.cs


示例19: Logger

 public Logger(string path, LoggingLevel level, params TextWriter[] otherOutputs)
 {
     _path = path;
     _level = level;
     _otherOutputs = otherOutputs;
     _messageBuffer = new List<string>();
     _extraWhiteSpace = new Regex(@"\s\s+");
 }
开发者ID:haunthy,项目名称:sensus,代码行数:8,代码来源:Logger.cs


示例20: LogException

 private static void LogException(object sender, LoggingLevel loggingLevel, Exception ex)
 {
     Exception exceptionToLog = ex;
     while (ex.InnerException != null)
     {
         ex = ex.InnerException;
     }
     LogMessage(sender, loggingLevel, string.Format("Exception thrown - {0}.{1} Stacktrace - {2}", ex.Message, Environment.NewLine, ex.StackTrace));
 }
开发者ID:SresgaminG,项目名称:ArmamutE,代码行数:9,代码来源:LogHelper.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Logic类代码示例发布时间:2022-05-24
下一篇:
C# LoggingEvent类代码示例发布时间: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