Once you have determined the switch value in your web.config , it is easy to get this value from your application by creating TraceSwitch with the same name:
private static TraceSwitch logSwitch = new TraceSwitch("logLevelSwitch", "This is your logLevelSwitch in the config file"); public static void Main(string[] args) {
Also, for this to work, as per the documentation:
You must enable tracing or debugging in order to use the switch. The following syntax is compiler specific. If you use compilers other than C # or Visual Basic, see the documentation for your compiler.
To enable C #, add the /d:DEBUG flag to the compiler command line when you compile your code, or you can add #define DEBUG to the top of your file. In Visual Basic, add the /d:DEBUG=True flag to the command line compiler.
To enable tracing using in C #, add the /d:TRACE flag to the compiler command line when compiling the code, or add #define TRACE to the top of the file. In Visual Basic, add the /d:TRACE=True flag to the compiler command line.
Yannick blondeau
source share