question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a way to turn off Diagnostic Tracing in projects

See original GitHub issue

Today, 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.

https://github.com/dotnet/sdk/blob/bc5c514a45a1a900b71d39a3541196bc2cf1bb0d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L21-L24

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
marcpopMSFTcommented, Dec 1, 2021

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', ''))

1reaction
KalleOlaviNiemitalocommented, Dec 4, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found