> ## 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.

# 附加探查器

> 将 dotnet trace 或 PIX 等探查器附加到 PlayFab Multiplayer Servers 生成,以调试图形和性能,并检索生成的输出日志。

本文介绍如何附加探查器以及如何获取输出文件。探查器用于帮助调试游戏服务器的图形和性能相关问题。若要使用 dotnet trace 或 PIX 等工具,首先需要上传你选择的探查器。然后将其关联到生成,输出文件将放入日志文件夹中。

不建议将探查器附加到生产生成,因为它可能会影响性能。
附加探查器的设置需要在创建生成时完成。目前我们不支持通过 Game Manager 附加探查器,因此你需要使用我们的 API 创建生成。有关详细信息,请参阅[演练:使用 PowerShell/API 部署生成](/services/playfab/multiplayer/servers/deploy-using-powershell-api)。

在创建生成时,监控配置下有一个资产引用字段。将资产引用包含在监控配置中。请确保你的资产已上传到 Game Manager 中。若要了解详情,请参阅[生成概述中的管理资产](/services/playfab/multiplayer/servers/build-overview)。

对于 Linux 服务器,以下是探查器执行脚本的示例。

```Bash Script theme={null}
sighdl()
{
    #This is the folder the monitoring output should be written to.
    monitoring_folder_path = "${PF_MONITORING_LOG_FOLDER}"

    #Code to end monitoring and copy the output 

    exit 0
}

#set up the trap function to catch the signals and exit gracefully
trap sighdl SIGKILL SIGINT SIGTERM
sleep 3600
```

对于 Windows 服务器,以下是探查器执行脚本的示例。

```PowerShell theme={null}
#Sample function that checks for the sentinel file's existence in order to end.
function Check_Sentinel_File()
{
    $fullPath = $Env:PF_SENTINEL_FILE
    while(!(Test-Path $fullPath)) { Start-Sleep 10}

    #PF_MONITORING_LOG_FOLDER contains the log folder where the monitoring output should be saved
    
    $outputPath = "{0}/{1}" -f $Env:PF_MONITORING_LOG_FOLDER, "output.txt"
    "I've died!" | Out-File $outputPath 
}

Check_Sentinel_File
```

* 请确保将输出保存在 **PF\_MONITORING\_LOG\_FOLDER** 环境变量设置的文件夹中,以确保输出得到保存。
* 服务器归档后,你可以下载日志,里面会有一个名为 **PlayfabProfilingOutput** 的文件夹。它将包含你在执行脚本中写入的内容,以及任何标准输出和错误。


## Related topics

- [附加内容（Add-ons）](/zh-CN/publishing/game-publishing/concepts/add-ons.md)
- [持久型附加内容](/zh-CN/publishing/game-publishing/concepts/add-ons/durable-add-ons.md)
- [PlayFab 附加组件](/zh-CN/services/playfab/live-service-management/service-gateway/add-ons/add-ons.md)
- [消耗型附加内容](/zh-CN/publishing/game-publishing/concepts/add-ons/consumable-add-ons.md)
- [附加内容捆绑包和季票](/zh-CN/publishing/game-publishing/concepts/add-ons/add-on-bundle.md)
