public static ILoggerFactory AddApplicationInsights(
            this ILoggerFactory factory,
            ApplicationInsightsSettings settings)
        {
            factory.AddProvider(new ApplicationInsightsLoggerProvider(null, settings));

            return(factory);
        }
 public static ILoggerFactory AddApplicationInsights(
     this ILoggerFactory factory,
     Func <string, LogLevel, bool> filter,
     ApplicationInsightsSettings settings)
 {
     factory.AddProvider(new ApplicationInsightsLoggerProvider(filter, settings));
     return(factory);
 }
        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;
            }
        }
Exemplo n.º 4
0
 public ApplicationInsightsLoggerProvider(Func <string, LogLevel, bool> filter, ApplicationInsightsSettings settings)
 {
     _filter   = filter;
     _settings = settings;
 }