/// <summary> /// Gets the configuration. /// </summary> /// <returns></returns> public static RollbarConfigSection GetConfiguration() { RollbarConfigSection configuration = ConfigurationManager.GetSection("rollbar") as RollbarConfigSection; if (configuration != null) { return(configuration); } return(new RollbarConfigSection()); }
/// <summary> /// Gets the configuration. /// </summary> /// <returns></returns> public static RollbarConfigSection GetConfiguration() { try { RollbarConfigSection configuration = ConfigurationManager.GetSection("rollbar") as RollbarConfigSection; return(configuration); } catch (Exception ex) { //let's just trace it for now: Trace.TraceError( "Error while attempting to get RollbarConfigSection:" + System.Environment.NewLine + ex ); return(null); } }
/// <summary> /// Gets the configuration. /// </summary> /// <returns></returns> public static RollbarConfigSection GetConfiguration() { try { RollbarConfigSection configuration = ConfigurationManager.GetSection("rollbar") as RollbarConfigSection; return(configuration); } catch (Exception ex) { //let's just trace it for now: traceSource.TraceEvent( TraceEventType.Warning, 0, $"Error while attempting to get RollbarConfigSection:{System.Environment.NewLine}{ex}"); return(null); } }
/// <summary> /// Loads the application settings. /// </summary> /// <param name="rollbarConfig">The configuration.</param> /// <param name="rollbarConfigSection">The application settings.</param> /// <returns>false when the configuration was not found, otherwise true.</returns> public static bool LoadAppSettings(RollbarConfig rollbarConfig, RollbarConfigSection rollbarConfigSection) { if (rollbarConfigSection == null) { return(false); } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.AccessToken)) { rollbarConfig.AccessToken = rollbarConfigSection.AccessToken; } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.Environment)) { rollbarConfig.Environment = rollbarConfigSection.Environment; } if (rollbarConfigSection.Enabled.HasValue) { rollbarConfig.Enabled = rollbarConfigSection.Enabled.Value; } if (rollbarConfigSection.Transmit.HasValue) { rollbarConfig.Transmit = rollbarConfigSection.Transmit.Value; } if (rollbarConfigSection.RethrowExceptionsAfterReporting.HasValue) { rollbarConfig.RethrowExceptionsAfterReporting = rollbarConfigSection.RethrowExceptionsAfterReporting.Value; } if (rollbarConfigSection.EnableLocalPayloadStore.HasValue) { rollbarConfig.EnableLocalPayloadStore = rollbarConfigSection.EnableLocalPayloadStore.Value; } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.LocalPayloadStoreFileName)) { rollbarConfig.LocalPayloadStoreFileName = rollbarConfigSection.LocalPayloadStoreFileName; } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.LocalPayloadStoreLocationPath)) { rollbarConfig.LocalPayloadStoreLocationPath = rollbarConfigSection.LocalPayloadStoreLocationPath; } if (rollbarConfigSection.MaxReportsPerMinute.HasValue) { rollbarConfig.MaxReportsPerMinute = rollbarConfigSection.MaxReportsPerMinute.Value; } if (rollbarConfigSection.ReportingQueueDepth.HasValue) { rollbarConfig.ReportingQueueDepth = rollbarConfigSection.ReportingQueueDepth.Value; } if (rollbarConfigSection.MaxItems.HasValue) { rollbarConfig.MaxItems = rollbarConfigSection.MaxItems.Value; } if (rollbarConfigSection.CaptureUncaughtExceptions.HasValue) { rollbarConfig.CaptureUncaughtExceptions = rollbarConfigSection.CaptureUncaughtExceptions.Value; } if (rollbarConfigSection.LogLevel.HasValue) { rollbarConfig.LogLevel = rollbarConfigSection.LogLevel.Value; } if (rollbarConfigSection.ScrubFields != null && rollbarConfigSection.ScrubFields.Length > 0) { rollbarConfig.ScrubFields = string.IsNullOrEmpty(rollbarConfigSection.ScrubFields) ? new string[0] : rollbarConfigSection.ScrubFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries); } if (rollbarConfigSection.ScrubWhitelistFields != null && rollbarConfigSection.ScrubWhitelistFields.Length > 0) { rollbarConfig.ScrubWhitelistFields = string.IsNullOrEmpty(rollbarConfigSection.ScrubWhitelistFields) ? new string[0] : rollbarConfigSection.ScrubWhitelistFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.EndPoint)) { rollbarConfig.EndPoint = rollbarConfigSection.EndPoint; } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyAddress)) { rollbarConfig.ProxyAddress = rollbarConfigSection.ProxyAddress; } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyUsername)) { rollbarConfig.ProxyUsername = rollbarConfigSection.ProxyUsername; } if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyPassword)) { rollbarConfig.ProxyPassword = rollbarConfigSection.ProxyPassword; } if (rollbarConfigSection.PayloadPostTimeout.HasValue) { rollbarConfig.PayloadPostTimeout = rollbarConfigSection.PayloadPostTimeout.Value; } if (rollbarConfigSection.PersonDataCollectionPolicies.HasValue) { rollbarConfig.PersonDataCollectionPolicies = rollbarConfigSection.PersonDataCollectionPolicies.Value; } if (rollbarConfigSection.IpAddressCollectionPolicy.HasValue) { rollbarConfig.IpAddressCollectionPolicy = rollbarConfigSection.IpAddressCollectionPolicy.Value; } return(true); }
/// <summary> /// Loads the application settings. /// </summary> /// <param name="rollbarConfig">The Rollbar configuration.</param> /// <returns>false when the configuration was not found, otherwise true.</returns> public static bool LoadAppSettings(RollbarConfig rollbarConfig) { return(AppConfigUtility.LoadAppSettings(rollbarConfig, RollbarConfigSection.GetConfiguration())); }