How do I make CloudConfigurationManager.GetSetting less verbose?

后端 未结 8 1390
天命终不由人
天命终不由人 2021-01-04 01:05

I\'m currently using CloudConfigurationManager.GetSetting(\"setting\") to get settings for my application, but it\'s writing logs of everything it\'s checking to the console

8条回答
  •  轮回少年
    2021-01-04 01:44

    Alternative option, if you're calling CloudConfigurationManager.GetSetting() in one part (ie, a wrapper/helper class):

    var oldListeners = Trace.Listeners.Cast().ToArray();
    Trace.Listeners.Clear();
    
    var stringValue = CloudConfigurationManager.GetSetting(key);
    Trace.Listeners.AddRange(oldListeners);
    

    First, we remove all listeners on Trace. Then we grab the setting, and re-add the listeners. Of course, this potentially could cause problems with threaded applications

提交回复
热议问题