you can set the level of a traceswitch through the application configuration file and then use the configured traceswitch level in your application.
You can create a TraceSwitch in your code and set the level directly to instrument a specific section of code.