Example #1
0
        public void Log <TState>(ApmLogLevel apmLogLevel, TState state, Exception e, Func <TState, Exception, string> formatter)
        {
            var nlogger = LogManager.GetLogger("");

            var message = formatter(state, e);

            if (e == null)
            {
                nlogger.Log(ConvertLevel(apmLogLevel), message);
            }
            else
            {
                nlogger.Log(ConvertLevel(apmLogLevel), e, message);
            }
        }
Example #2
0
        private static Microsoft.Extensions.Logging.LogLevel Convert(LogLevel logLevel)
        {
            switch (logLevel)
            {
            case LogLevel.Trace: return(Microsoft.Extensions.Logging.LogLevel.Trace);

            case LogLevel.Debug: return(Microsoft.Extensions.Logging.LogLevel.Debug);

            case LogLevel.Information: return(Microsoft.Extensions.Logging.LogLevel.Information);

            case LogLevel.Warning: return(Microsoft.Extensions.Logging.LogLevel.Warning);

            case LogLevel.Error: return(Microsoft.Extensions.Logging.LogLevel.Error);

            case LogLevel.Critical: return(Microsoft.Extensions.Logging.LogLevel.Critical);

            case LogLevel.None:
            default: return(Microsoft.Extensions.Logging.LogLevel.None);
            }
        }
Example #3
0
        private static NLogLevel ConvertLevel(ApmLogLevel apmLogLevel)
        {
            switch (apmLogLevel)
            {
            case ApmLogLevel.Trace: return(NLogLevel.Trace);

            case ApmLogLevel.Debug: return(NLogLevel.Debug);

            case ApmLogLevel.Information: return(NLogLevel.Info);

            case ApmLogLevel.Warning: return(NLogLevel.Warn);

            case ApmLogLevel.Error: return(NLogLevel.Error);

            case ApmLogLevel.Critical: return(NLogLevel.Fatal);

            case ApmLogLevel.None: return(NLogLevel.Off);

            default: return(NLogLevel.Info);
            }
        }
 public void Log <TState>(LogLevel level, TState state, Exception e, Func <TState, Exception, string> formatter) =>
 _logger.Log(Convert(level), new EventId(), state, e, formatter);
 public bool IsEnabled(LogLevel level) => _logger.IsEnabled(Convert(level));
Example #6
0
 public bool IsEnabled(ApmLogLevel level) => _logger.Value.IsEnabled(ConvertLevel(level));
Example #7
0
 public bool IsEnabled(ApmLogLevel level) => true;