How can I disable application insights automatically when using a debug configuration and enable it only on release?
Is it possible to do this without creating another instrumentation key only for debug?
I have trackevent
statements scattered all over the code, enclosing them inside a debug preprocessor check is not an ideal solution.
My current solution is to set the Build Action
of the ApplicationInsights.config
file to None
so that it's not copied to the project's output directory, but this isn't a process that can be automated based on the active build configuration.
There is a Developer Mode but needs to be changed manually (if it was possible to conditionally set the config file, emptying the instrumentationkey solved problem as well). See http://apmtips.com/blog/2015/02/02/developer-mode/
You can try to use TelemetryConfiguration.DisableTelemetry Property Something like this way..
#if DEBUG
TelemetryConfiguration.Active.DisableTelemetry = true;
#endif