-
-
Notifications
You must be signed in to change notification settings - Fork 142
Client Configuration Values
--
Read about Client Configuration Values on the UI Documentation Page
The below example demonstrates how we would turn on or off log event submissions at runtime without redeploying the app or changing server config settings.
First, we add a (completely arbitrary for this example) enableLogSubmission
client configuration value key with value true
in the Project's Settings in the Exceptionless dashboard.
Then, we register a new client side plugin that runs each time an event is created. If our key (enableLogSubmission
) is set to false and the event type is set to log, we will discard the event.
ExceptionlessClient.Default.Configuration.AddPlugin("Conditionally cancel log submission", 100, context => {
var enableLogSubmission = context.Client.Configuration.Settings.GetBoolean("enableLogSubmission", true);
// only cancel event submission if it’s a log event and enableLogSubmission is false
if (context.Event.Type == Event.KnownTypes.Log && !enableLogSubmission) {
context.Cancel = true;
}
});
The GetBoolean
method checks the enableLogSubmission
key. This helper method makes it easy to consume saved client configuration values. The first parameter defines the settings key (name). The second parameter is optional and allows you to set a default value if the key doesn’t exist in the settings or was unable to be converted to the proper type (e.g., a boolean).
We have a few helpers to convert string configuration values to different system types. These methods also contain overloads that allow you to specify default values.
###Helpers###
GetString
GetBoolean
GetInt32
GetInt64
GetDouble
GetDateTime
GetDateTimeOffset
GetGuid
-
GetStringCollection
(breaks a comma delimited list into an IEnumerable of strings)
To be notified when client configuration settings change, subscribe to them using the below code.
ExceptionlessClient.Default.Configuration.Settings.Changed += SettingsOnChanged;
private void SettingsOnChanged(object sender, ChangedEventArgs<KeyValuePair<string, string>> args) {
Console.WriteLine("The key {0} was {1}", args.Item.Key, args.Action);
}
Looking for General Exceptionless Documentation, UI Documentation, or Documentation for another Client?
Visit the Primary Exceptionless Documentation Page and go from there.