public static ExceptionlessSection GetApplicationConfiguration(IExceptionlessLogAccessor logAccessor) { if (!_configRead) { try { _configRead = true; _configSection = ConfigurationManager.GetSection("exceptionless") as ExceptionlessSection; } catch (Exception ex) { logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message); } } return(_configSection); }
public static ExceptionlessSection GetApplicationConfiguration(IExceptionlessLogAccessor logAccessor) { if (!_configRead) { try { _configRead = true; _configSection = ConfigurationManager.GetSection("exceptionless") as ExceptionlessSection; } catch (Exception ex) { logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message); } } return _configSection; }
private static void ReadApplicationConfiguration(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor) { try { ExceptionlessSection exceptionlessSection = GetApplicationConfiguration(logAccessor); if (exceptionlessSection == null) { return; } // only update if not null if (!String.IsNullOrEmpty(exceptionlessSection.ApiKey)) { configuration.ApiKey = exceptionlessSection.ApiKey; } // if an appsetting is present for apikey, then it will override the other api keys string apiKeyOverride = ConfigurationManager.AppSettings["Exceptionless:ApiKey"] ?? String.Empty; if (!String.IsNullOrEmpty(apiKeyOverride)) { configuration.ApiKey = apiKeyOverride; } if (!String.IsNullOrEmpty(exceptionlessSection.QueuePath)) { configuration.QueuePath = exceptionlessSection.QueuePath; } if (!String.IsNullOrEmpty(exceptionlessSection.ServerUrl)) { configuration.ServerUrl = exceptionlessSection.ServerUrl; } configuration.Enabled = exceptionlessSection.Enabled; if (exceptionlessSection.EnableSSL.HasValue) { configuration.EnableSSL = exceptionlessSection.EnableSSL.Value; } if (exceptionlessSection.EnableLogging.HasValue) { configuration.EnableLogging = exceptionlessSection.EnableLogging.Value; } if (!String.IsNullOrEmpty(exceptionlessSection.LogPath)) { configuration.LogPath = exceptionlessSection.LogPath; } // if a log path is specified and enable logging setting isn't specified, then enable logging. if (!String.IsNullOrEmpty(exceptionlessSection.LogPath) && !exceptionlessSection.EnableLogging.HasValue) { configuration.EnableLogging = true; } if (exceptionlessSection.Settings == null) { return; } foreach (NameValueConfigurationElement setting in exceptionlessSection.Settings) { if (!String.IsNullOrEmpty(setting.Name)) { configuration[setting.Name] = setting.Value; } } } catch (ConfigurationErrorsException ex) { logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message); } }