Exemple #1
0
        public ApplicationInsightsLogger(string name, Func <string, LogLevel, bool> filter, ApplicationInsightsSettings settings)
        {
            _name            = string.IsNullOrEmpty(name) ? nameof(ApplicationInsightsLogger) : name;
            _filter          = filter;
            _settings        = settings;
            _telemetryClient = new TelemetryClient();

            if (_settings.LocalEnvironmentMode.HasValue)
            {
                TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = _settings.LocalEnvironmentMode;
            }

            if (!_settings.LocalEnvironmentMode.Value)
            {
                if (string.IsNullOrWhiteSpace(_settings.InstrumentationKey))
                {
                    throw new ArgumentNullException(nameof(_settings.InstrumentationKey));
                }

                TelemetryConfiguration.Active.InstrumentationKey = _settings.InstrumentationKey;
                _telemetryClient.InstrumentationKey = _settings.InstrumentationKey;
            }
        }
 public ApplicationInsightsLoggerProvider(Func <string, LogLevel, bool> filter, ApplicationInsightsSettings settings)
 {
     _filter   = filter;
     _settings = settings;
 }