Exemple #1
0
        /// <summary>
        /// 记录日志。
        /// </summary>
        /// <param name="level">日志等级。</param>
        /// <param name="exception">异常。</param>
        /// <param name="format">格式。</param>
        /// <param name="args">参数。</param>
        public void Log(LogLevel level, Exception exception, string format, params object[] args)
        {
            var logLevel = LogUtilities.ConvertLogLevel(level);

            var logEventInfo = LogEventInfo.Create(logLevel, _logger.Name, CultureInfo.CurrentCulture, format, args);

            if (exception != null)
            {
                logEventInfo.Exception = new DetailedException(exception);
            }
            _logger.Log(logEventInfo);
        }
Exemple #2
0
 /// <summary>
 /// 当前日志等级是否可以记录。
 /// </summary>
 /// <param name="level">日志等级。</param>
 /// <returns>是否可以记录。</returns>
 public bool IsEnabled(LogLevel level)
 {
     return(_logger.IsEnabled(LogUtilities.ConvertLogLevel(level)));
 }