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


C# LogLevel类代码示例

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


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

示例1: WriteConsole

 protected virtual void WriteConsole (LogLevel level, string tag, string message, Exception exc)
 {
     Console.WriteLine ("[{1}] {0}: {2}", level, tag, message);
     if (exc != null) {
         Console.WriteLine (exc.ToString ());
     }
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:7,代码来源:BaseLogger.cs

示例2: ToLog4Net

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

示例3: Log

 public override void Log(LogLevel level, string msg, params object[] args)
 {
     lock (_lock)
     {
         var previous = Console.ForegroundColor;
         switch (level)
         {
             case LogLevel.Debug:
                 Console.ForegroundColor = ConsoleColor.Blue;
                 break;
             case LogLevel.Info:
                 Console.ForegroundColor = ConsoleColor.White;
                 break;
             case LogLevel.Warning:
                 Console.ForegroundColor = ConsoleColor.Yellow;
                 break;
             case LogLevel.Error:
                 Console.ForegroundColor = ConsoleColor.Red;
                 break;
             case LogLevel.Fatal:
                 Console.ForegroundColor = ConsoleColor.Magenta;
                 break;
             default:
                 break;
         }
         Console.WriteLine(NameFormatToPositionalFormat(msg), args);
         Console.ForegroundColor = previous;
     }
 }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:29,代码来源:ConsoleLogger.cs

示例4: Write

 public static void Write (LogLevel level, string msg, params object[] args)
 {
     lock (loggers) {
         foreach (var l in loggers)
             l.Write (level, msg, args);
     }
 }
开发者ID:CalebKoch,项目名称:PushSharp,代码行数:7,代码来源:Log.cs

示例5: Write

        /// <summary>
        /// ��¼��־�ķ���,�÷���Ĭ�ϰ���־��Ϣ��¼���ı��ļ���
        /// </summary>
        /// <param name="logMsg">��־�ı���Ϣ</param>
        /// <param name="logLevel">��־�ȼ�</param>
        public void Write(string logMsg, LogLevel logLevel)
        {
            MetaLog metaLog = new TxtMetaLog(logMsg);
            metaLog.Level = logLevel;

            this.Write(metaLog);
        }
开发者ID:peterchen,项目名称:gaopincai,代码行数:12,代码来源:SyncLogger.cs

示例6: IsLoggingEnabled

 public bool IsLoggingEnabled(LogLevel logLevel)
 {
     log4net.ILog logger;
     if (_loggerName != null && _loggerName.Trim() != string.Empty)
         logger = LogManager.GetLogger(_loggerName);
     else
     {
         Type type = new StackFrame(_frameToSkip, false).GetMethod().DeclaringType;
         logger = LogManager.GetLogger(type);
     }
     switch (logLevel)
     {
         case LogLevel.Debug:
             return logger.IsDebugEnabled;
         case LogLevel.Info:
             return logger.IsInfoEnabled;
         case LogLevel.Warn:
             return logger.IsWarnEnabled;
         case LogLevel.Error:
             return logger.IsErrorEnabled;
         case LogLevel.Fatal:
             return logger.IsFatalEnabled;
         case LogLevel.Off:
             return false;
         default:
             throw new Exception(string.Format("Unrecognized log level '{0}'.", logLevel.ToString()));
     }
 }
开发者ID:jmptrader,项目名称:WebFrameworkMVC,代码行数:28,代码来源:Log4netAdapter.cs

示例7: Write

        /// <summary>
        /// Logs an entry to the source
        /// </summary>
        /// <param name="logLevel">Used level.</param>
        /// <param name="msg">Message.</param>
        /// <param name="exception">The exception (or null).</param>
        public override void Write(LogLevel logLevel, string msg, Exception exception)
        {
            if (logLevel < _minLevel)
                return;

            _innerLogger.Write(logLevel, msg, exception);
        }
开发者ID:2594636985,项目名称:griffin.networking,代码行数:13,代码来源:FilteredLogger.cs

示例8: SimpleLogItem

 public SimpleLogItem(LogLevel level, string message, string info)
 {
     this.time = DateTime.Now;
     this.level = level;
     this.message = message;
     this.info = info;
 }
开发者ID:Kundara,项目名称:project1,代码行数:7,代码来源:SimpleLogItem.cs

示例9: FileLog

 public FileLog(string filePath, LogLevel minLevel = LogLevel.Info)
 {
     AttemptToCreateDirectory(filePath);
     _logFileStream = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
     _minLevel = minLevel;
     _logFile = filePath;
 }
开发者ID:lynxx131,项目名称:dotnet.microservice,代码行数:7,代码来源:FileLog.cs

示例10: ActivityMonitorLineSender

 /// <summary>
 /// Used only by filtering extension methods (level is filtered and not None) or by static FakeLineSender (level is None).
 /// </summary>
 internal ActivityMonitorLineSender( IActivityMonitor monitor, LogLevel level, string fileName, int lineNumber )
     : base( level, fileName, lineNumber )
 {
     Debug.Assert( FakeLineSender == null || ((level & LogLevel.IsFiltered) != 0 && MaskedLevel != LogLevel.None), 
         "The level is already filtered and not None or we are initializing the static FakeLineSender." );
     _monitor = monitor;
 }
开发者ID:Invenietis,项目名称:ck-core,代码行数:10,代码来源:ActivityMonitorLineSender.cs

示例11: ManagementConsoleLogTracer

 public ManagementConsoleLogTracer(string logLevel)
 {
     switch (logLevel)
     {
         case "Fine":
             _logLevel = LogLevel.Fine;
             break;
         case "Info":
             _logLevel = LogLevel.Info;
             break;
         case "Fatal":
             _logLevel = LogLevel.Fatal;
             break;
         case "Warning":
             _logLevel = LogLevel.Warning;
             break;
         case "Debug":
             _logLevel = LogLevel.Debug;
             break;
         case "Error":
             _logLevel = LogLevel.Error;
             break;
         default:
             throw new ArgumentException( "Unhandled log level: " + logLevel);
     }
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:26,代码来源:ManagementConsoleLogTracer.cs

示例12: Log

        public static void Log(LogLevel level, string message, Exception exception = null)
        {
            var builder = new StringBuilder();

            builder.Append(DateTime.Now);
            builder.Append(" [").Append(level.ToString().ToUpper()).Append("] ");
            builder.Append(message);

            //vamos imprimir para tela sem o stack track.
            switch (level)
            {
                case LogLevel.Debug:
                    Console.ForegroundColor = ConsoleColor.DarkBlue;
                    break;
                case LogLevel.Warn:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;
                case LogLevel.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;
            }

            Console.WriteLine(builder.ToString());
            Console.ResetColor();

            if (exception != null)
            {
                builder.Append('\n');
                builder.Append("Caused by: ").Append(exception.Message).Append('\n');
                builder.Append("Stack trace:\n");
                builder.Append(exception.StackTrace);
            }

            Write(builder.ToString());
        }
开发者ID:sridhar19091986,项目名称:simpleot,代码行数:35,代码来源:Logger.cs

示例13: Log

        // ReSharper disable ExplicitCallerInfoArgument
        public static void Log(
            this ILogger logger,
            LogLevel logLevel,
            Exception exception,
            string message = null,
            [CallerMemberName] string callerMemberName = null,
            [CallerFilePath] string callerFilePath = null,
            [CallerLineNumber] int callerLineNumber = 0)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            if (logLevel != LogLevel.Audit && !logger.IsEnabled(logLevel))
            {
                return;
            }

            var logEntry = DefaultLogEntryFactory.Current.CreateLogEntry();

            logEntry.Level = logLevel;
            logEntry.SetException(exception);
            logEntry.Message = message ?? exception.Message;

            logger.LogAsync(logEntry, callerMemberName, callerFilePath, callerLineNumber);
        }
开发者ID:Orthak,项目名称:Rock.Logging,代码行数:28,代码来源:Exception.cs

示例14: Warning

 /// <summary>
 /// 初始化应用程序异常
 /// </summary>
 /// <param name="message">错误消息</param>
 /// <param name="code">错误码</param>
 /// <param name="level">日志级别</param>
 /// <param name="exception">异常</param>
 public Warning( string message, string code, LogLevel level, Exception exception )
     : base( message ?? "", exception ) 
 {
     Code = code;
     Level = level;
     _message = GetMessage();
 }
开发者ID:reckcn,项目名称:CSharp,代码行数:14,代码来源:Warning.cs

示例15: Log

 public static void Log(LogLevel level, object sender, string message, params object[] args)
 {
     string typeName = (sender == null ? "(null)" : sender.GetType ().FullName);
     LogEventInfo info = new LogEventInfo (_levelMap[level], typeName, string.Format (message, args));
     info.Context.Add ("sender", sender);
     _logger.Log (info);
 }
开发者ID:kazuki,项目名称:p2pncs,代码行数:7,代码来源:Logger.cs


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