Provide a way to turn off Diagnostic Tracing in projects
See original GitHub issueToday, tracing support is always enabled by default, unless it is overridden externally (to the project), for e.g., at the msbuild command-line. There seems to be no way - at least no easy way - to control this in a project.
This could be made opt-in by supplying a property - for e.g., EnableDiagnosticTracing
- that’s true
by default for compatibility purposes.
<PropertyGroup>
<DefineConstants Condition=" '$(DefineConstants)' != '' ">$(DefineConstants);</DefineConstants>
<DefineConstants Condition="'$(EnableDiagnosticTracing)'!='false'">$(DefineConstants)TRACE</DefineConstants>
</PropertyGroup>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
c# - Turning tracing off via app.config
This way, you could make all logging within your application happen at the same level (or be turned off or go the same...
Read more >MFC Debugging Techniques - Visual Studio (Windows)
Learn techniques for debugging MFC programs, including: coded breakpoints, tracing, memory leak detection, object memory dumps, ...
Read more >Configuring Tracing - WCF
Learn how to enable tracing, configure trace sources, set activity tracing and propagation, and set trace listeners to access traces in WCF.
Read more >Enable debugging and tracing of applications
In this article, you will learn how to enable instrumentation for your application - both debugging and tracing. Debug and Trace classes. The...
Read more >How to protect your privacy in Windows 11
To turn it off, select Settings > Privacy & security > App diagnostics, and in the App diagnostic access section, move the slider...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Moving this out of the props could be breaking if customers were overwriting that value. Something simpler than the regex like the below could be added to a targets file (probably in the CSHARP.targets file) based on a condition. If you’re interested in doing that work, we’d accept the PR.
$(DefineConstants.Replace('TRACE', ''))
Visual Basic uses the DefineTrace property:
https://github.com/dotnet/sdk/blob/c53c8ac81e1bcb8118c31bc4f5622396c72e9959/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.VisualBasic.props#L26-L32
https://github.com/dotnet/msbuild/blob/4adc47707f27d0dce03cee9e4651d599e7ff265f/src/Tasks/Microsoft.VisualBasic.CurrentVersion.targets#L141
If DefineTrace in Visual Basic controls whether TRACE is added, and EnableDiagnosticTracing in C# controls whether TRACE is removed after having been added, it’s good that the properties have different names. Still, it is unfortunate if VB’s simpler mechanism cannot be used for C# because of compatibility.