Search Results for

    Show / Hide Table of Contents

    Enable and read runtime logs

    中文 | English

    Run this command at the repository root to replay the examples through the local Unity MCP.

    python Docs/Manual/manual/tools/tutorials.py run runtime-log
    
    Click to expand MCP actionsClick to collapse MCP actions

    Prepare the teaching sample. The recipe provides ${variables}.

    {
      "variables": {
        "marker": "${fixture}/log.debug"
      },
      "calls": [
        {
          "tool": "invoke",
          "arguments": {
            "path": "static:UnityEditor.AssetDatabase/CreateFolder",
            "args": [
              "${fixtureParent}",
              "${folder}"
            ]
          },
          "expect": {
            "regex": "\\(String\\) [a-f0-9]{32}"
          }
        }
      ]
    }
    

    1. Confirm the paths

    Connect to the app you are troubleshooting and read Application.persistentDataPath. The release build looks for log.debug in that directory. To find the on-disk console log for the connected instance, read Application.consoleLogPath.

    Click to expand MCP actionsClick to collapse MCP actions
    [
      {
        "tool": "inspect",
        "arguments": {
          "path": "static:UnityEngine.Application/persistentDataPath"
        },
        "expect": {
          "contains": "(String)"
        }
      },
      {
        "tool": "inspect",
        "arguments": {
          "path": "static:UnityEngine.Application/consoleLogPath"
        },
        "expect": {
          "contains": "(String)"
        }
      }
    ]
    

    2. Enable logging in a release build

    Create log.debug in the persistent data directory. The file can be empty. Check that the system has kept the exact filename, then restart the game so it can detect the marker. The editor and debug builds enable logging by default.

    Click to expand MCP actionsClick to collapse MCP actions

    The replay creates a marker in a temporary directory. Use the application’s own persistent data directory for a release player.

    [
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/WriteAllText",
          "args": [
            "${marker}",
            ""
          ]
        },
        "expect": {
          "contains": "OK:"
        }
      },
      {
        "tool": "invoke",
        "arguments": {
          "path": "static:System.IO.File/Exists",
          "args": [
            "${marker}"
          ]
        },
        "expect": {
          "contains": "(Boolean) True"
        }
      }
    ]
    

    3. Read the log

    Call logs on the connected instance to read recent entries in the debug buffer. Include the time and the steps that produced the issue when reporting a problem. The example verifies path queries, a temporary marker and the MCP log query. Release-build restart behavior was not tested.

    Click to expand MCP actionsClick to collapse MCP actions
    [
      {
        "tool": "logs",
        "arguments": {
          "count": 20
        }
      }
    ]
    
    In this article
    Back to top Panzer War Document