コード例 #1
0
 public void Write(Microsoft.Framework.Logging.LogLevel logLevel, int eventId, object state, Exception exception, Func <object, Exception, string> formatter)
 {
     Logger.Information(
         string.Format("LogLevel: {0}, EventId: {1}, State: {2}, Exception: {3}, Formatter: {4}, LoggerName: {5}, Scope: {6}",
                       logLevel, eventId, state, exception, formatter, _name, _scope
                       ));
 }
コード例 #2
0
        private NLog.LogLevel GetLogLevel(Microsoft.Framework.Logging.LogLevel logLevel)
        {
            switch (logLevel)
            {
            case Microsoft.Framework.Logging.LogLevel.Verbose: return(NLog.LogLevel.Debug);

            case Microsoft.Framework.Logging.LogLevel.Information: return(NLog.LogLevel.Info);

            case Microsoft.Framework.Logging.LogLevel.Warning: return(NLog.LogLevel.Warn);

            case Microsoft.Framework.Logging.LogLevel.Error: return(NLog.LogLevel.Error);

            case Microsoft.Framework.Logging.LogLevel.Critical: return(NLog.LogLevel.Fatal);
            }
            return(NLog.LogLevel.Debug);
        }
コード例 #3
0
        public void Log(Microsoft.Framework.Logging.LogLevel logLevel, int eventId, object state, Exception exception, Func <object, Exception, string> formatter)
        {
            var nLogLogLevel = GetLogLevel(logLevel);
            var message      = string.Empty;

            if (formatter != null)
            {
                message = formatter(state, exception);
            }
            else
            {
                message = LogFormatter.Formatter(state, exception);
            }
            if (!string.IsNullOrEmpty(message))
            {
                var eventInfo = LogEventInfo.Create(nLogLogLevel, _logger.Name, message, exception);
                eventInfo.Properties["EventId"] = eventId;
                _logger.Log(eventInfo);
            }
        }
コード例 #4
0
 public bool IsEnabled(Microsoft.Framework.Logging.LogLevel logLevel)
 {
     return(_logger.IsEnabled(GetLogLevel(logLevel)));
 }
コード例 #5
0
 public bool IsEnabled(Microsoft.Framework.Logging.LogLevel logLevel)
 {
     return(_enabled);
 }