Share via


Log info to the Output window using tracepoints in Visual Studio

Tracepoints allow you to log information to the Output window under configurable conditions without modifying or stopping your code. This feature is supported for both managed languages (C#, Visual Basic, F#) and native code as well as languages such as JavaScript and Python.

Note

For information on logging information to the Output window programmatically using .NET APIs, see Send messages to the Output window.

Let's take an example

Set tracepoints in source code

Actions menu

Conditions menu

Conditions allow you to filter your output messages, so they display only under certain scenarios. There are three main kinds of conditions available to you.

Conditional expression

Hit count

Filter

Considerations

While tracepoints are intended to make debugging a cleaner, and smoother experience. There are some considerations you should be aware of when it comes to using them.

Sometimes when you inspect a property or attribute of an object, its value can change. If the value changes during inspection, it's not a bug caused by the tracepoint feature itself. However, using tracepoints to inspect objects doesn't avoid these accidental modifications.

The way that expressions are evaluated in the Action message box may be different than the language you're currently using for development. For example, to output a string you don't need to wrap a message in quotes even if you normally would while using Debug.WriteLine() or console.log(). Also, the curly brace syntax ({ }) to output expressions may also be different than the convention for outputting values in your development language. (However, the contents within the curly braces ({ }) should still be written using your development language’s syntax).

If you're trying to debug a live application, and looking for a similar feature, check out our log point feature in the Snapshot Debugger. The snapshot debugger is a tool used to investigate issues in production applications. Logpoints also allow you to send messages to the Output Window without having to modify source code and don't affect your running application. For more information, see Debug live Azure application.