public static ILoggerFactory AddApplicationInsights(
     this ILoggerFactory factory,
     Func <string, LogLevel, bool> filter,
     ApplicationInsightsSettings settings)
 {
     factory.AddProvider(new ApplicationInsightsLoggerProvider(filter, settings));
     return(factory);
 }
        public static ILoggerFactory AddApplicationInsights(
            this ILoggerFactory factory,
            ApplicationInsightsSettings settings)
        {
            factory.AddProvider(new ApplicationInsightsLoggerProvider(null, settings));

            return(factory);
        }
Пример #3
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.DeveloperMode.HasValue)
            {
                TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = _settings.DeveloperMode;
            }

            if (!_settings.DeveloperMode.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;
 }