--- title: Logging and debugging summary: X4 logs, useful diagnostic markers and the difference between import, event, execution and result failures. section: start kind: guide status: reference tags: ["X4","modding","debugging"] sources: ["https://wiki.egosoft.com/X%20Rebirth%20Wiki/Modding%20support/Mission%20Director%20Guide/"] --- ## Enable the log Use the launch arguments below for script diagnostics. Find the log in the user profile actually used by the game process, especially with multiple test profiles. Add a distinctive `debug_text` marker in MD. Lua UI can use the game's `DebugError` where available; the example checks its event API prerequisite. ```text -debug scripts -logfile debuglog.txt ``` ```xml ``` ```lua if type(RegisterEvent) ~= "function" then DebugError("[WIKI] UI event API unavailable") return end ``` ## Four different failures | Stage | Check | | --- | --- | | Import | XML validity, schema, filename, dependencies | | Event | screen/control names and callback registration time | | Execution | Argument types, object existence and permissions | | Result | Actual value, object, account or queue in game | Do not log generic success immediately after sending an event. Use precise markers such as `sent`, `received`, `validated`, `applied` and `readback_ok`. ## Collect one complete snapshot Read every required fact before reporting differences. Stopping at the first mismatch loses evidence about other objects and may force an unnecessary expensive rerun. The inspected UI environment lacked the standard Lua `debug` library; verify availability before depending on it. Short bounded entry/argument markers helped investigate map callbacks.