> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Debug Tracing

> Enable PlayFab Services SDK debug tracing: set verbosity, route output to the Visual Studio debugger, forward to game logs, or write traces to file.

This PlayFab SDK supports extensible debug tracing. Use debug tracing when you're encountering errors and want a full picture of what calls the game makes and the results the server returns. There are options to control the trace verbosity and integrate with your game's own debug logs. You can also direct output to the Output pane in Visual Studio.

## Enable and set Verbosity

The following code example enables debug tracing and sets the debug error level to **Verbose**. You can also set the debug error level to **Error** to show only trace failed calls; or to **Off** to disable tracing.)

The resulting debug output is sent to the Output pane when running your project in Visual Studio.

```cpp theme={null}
HCSettingsSetTraceLevel(HCTraceLevel::Verbose);
HCTraceSetTraceToDebugger(true);
```

## Connect to Game logs

To connect PlayFab's trace debugging to your game's own debug logs, use **HCTraceSetClientCallback**. Provide a callback that can take PlayFab trace output and direct to game logs.

```cpp theme={null}
void CALLBACK TraceCallback(
    _In_z_ char const* areaName,
    enum HCTraceLevel level,
    uint64_t threadId,
    uint64_t timestamp,
    _In_z_ char const* message
)
{
    // Log info
}

HCTraceSetClientCallback(TraceCallback);
```

## Write traces to a file

To write PlayFab trace output to a log file on disk, call [**PFTraceEnableTraceToFile**](/services/playfab/api-references/c/pftrace/functions/pftraceenabletracetofile) with the directory where the trace file should be created. Call this function after initialization.

```cpp theme={null}
PFTraceEnableTraceToFile("C:\\GameLogs\\PlayFabTraces");
```

This function is independent of the HCTrace functions above. You can use file tracing alongside debugger output and client callbacks.

## Reference

[PlayFab API reference documentation](/services/playfab/api-references/c/pftrace/pftrace_members)
[Trace API reference documentation](/reference/live/httpclient/trace/trace_members)


## Related topics

- [Debug tracing in the PlayFab Unified SDK](/services/playfab/sdks/unified-sdk/debug-trace.md)
- [Game Saves quickstart](/services/playfab/player-progression/game-saves/quickstart.md)
- [Quickstart GDK](/services/playfab/sdks/c/quickstart-gdk.md)
- [Quickstart iOS](/services/playfab/sdks/c/quickstart-ios.md)
- [Quickstart Linux](/services/playfab/sdks/c/quickstart-linux.md)
