Пример #1
0
            private void DoWrite(IDictionary <string, object> parameters, LogLevel level, string message, Exception ex)
            {
                if (parameters == null)
                {
                    throw new ArgumentNullException(nameof(parameters));
                }
                if (_parameter != null)
                {
                    parameters.Add(_parameter, _value());
                }
                if (_parent == null)
                {
                    using (_logger.BeginScope(parameters))
                        switch (level)
                        {
                        case LogLevel.Trace:
                            _logger.LogTrace(0, ex, message);
                            break;

                        case LogLevel.Debug:
                            _logger.LogDebug(0, ex, message);
                            break;

                        case LogLevel.Information:
                            _logger.LogInformation(0, ex, message);
                            break;

                        case LogLevel.Warning:
                            _logger.LogWarning(0, ex, message);
                            break;

                        case LogLevel.Error:
                            _logger.LogError(0, ex, message);
                            break;

                        case LogLevel.Critical:
                            _logger.LogCritical(0, ex, message);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException(nameof(level), level, null);
                        }
                }
                else
                {
                    _parent.DoWrite(parameters, level, message, ex);
                }
            }