> ## 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 in the PlayFab Unified SDK

> Enable and configure debug tracing in the PlayFab Unified SDK: set HCTraceLevel verbosity, route output to Visual Studio, or forward to custom game logs.

The PlayFab Unified SDK provides an extensible debug tracing system to help developers monitor internal API behavior, track errors, and integrate PlayFab logs into their game's logging infrastructure. Debug output can also be routed to the Visual Studio Output pane during development.

## Overview

Debug tracing is useful for:

* Monitoring PlayFab SDK requests and responses
* Diagnosing API call failures
* Integrating with custom logging systems
* Adjusting log verbosity per environment (development vs. production)
* Debugging multithreaded issues via thread ID tracking

## Enabling and Configuring Tracing

You can enable tracing, set verbosity, and configure where output is sent using the following API calls:

```cpp theme={null}
HCSettingsSetTraceLevel(HCTraceLevel::Verbose);  // Verbose, Error, or Off
HCTraceSetTraceToDebugger(true);                 // Route to Visual Studio Output window
HCTraceSetClientCallback(TraceCallback);         // Custom trace handler
```

## Trace Levels

| Level                   | Description                            |
| ----------------------- | -------------------------------------- |
| `HCTraceLevel::Off`     | Disables all tracing                   |
| `HCTraceLevel::Error`   | Logs only failed API calls             |
| `HCTraceLevel::Verbose` | Logs all requests, responses, metadata |

## Integrating with Custom Logging Systems

### GameLog Helper Function

```cpp theme={null}
#include <iostream>
#include <string>

void GameLog(const std::string& levelStr, const std::string& message)
{
    std::cout << "[" << levelStr << "] " << message << std::endl;
}
```

### Trace Callback Example

```cpp theme={null}
#include <sstream>

void CALLBACK TraceCallback(
    const char* areaName,
    HCTraceLevel level,
    uint64_t threadId,
    uint64_t timestamp,
    const char* message)
{
    std::ostringstream oss;

    std::string levelStr;
    switch (level)
    {
        case HCTraceLevel::Error:   levelStr = "Error";   break;
        case HCTraceLevel::Verbose: levelStr = "Verbose"; break;
        default:                    levelStr = "Log";     break;
    }

    oss << "[" << areaName << "] [Thread " << threadId << "] " << message;
    GameLog(levelStr, oss.str());
}
```

### Initialization

```cpp theme={null}
void InitializePlayFabTracing()
{
    HCSettingsSetTraceLevel(HCTraceLevel::Verbose);
    HCTraceSetTraceToDebugger(true);  // Set to false to suppress VS Output pane
    HCTraceSetClientCallback(TraceCallback);
}
```

## Best Practices

* **Verbose in development**: Enables comprehensive tracing for debugging and QA.
* **Error or Off in production**: Reduces performance impact and log volume.
* **Centralize logging**: Use a unified `GameLog` function or similar to aggregate logs from PlayFab and other systems.
* **Debug multithreading**: Use the thread ID in logs to identify concurrency issues.

## See also

* [Asynchronous operations](/services/playfab/sdks/unified-sdk/async-model)
* [Memory management](/services/playfab/sdks/unified-sdk/memory-management)
* [Tracing and diagnostics](/services/playfab/sdks/unified-sdk/debug-trace)


## Related topics

- [PlayFab Unified SDK](/services/playfab/sdks/unified-sdk/overview.md)
- [Memory management in the PlayFab Unified SDK](/services/playfab/sdks/unified-sdk/memory-management.md)
- [Making async calls in the PlayFab Unified SDK](/services/playfab/sdks/unified-sdk/async-model.md)
- [PlayFab SDK Products](/services/playfab/sdks/sdk-products.md)
- [Game Saves Implementation with October 2025 GDK](/services/playfab/player-progression/game-saves/october-2025-gdk-changes.md)
