Skip to content

Instantly share code, notes, and snippets.



Last active Dec 1, 2020
What would you like to do?
Run X4 Foundations in debug mode with timestamped file names so you don't lose them.

Run X4 Foundations in debug mode.

The handy script below (x4-debug.bat) can be used as a shortcut to start x4 in debug mode. You get:

  • All debug messages turned on
  • All debug logs sent to a timestamped file, so you dont lose anything


Copy paste the code in the file below, then update the value for X4_EXE_PATH - change it to wherever X4.exe is located. Your debug logs will be available in the Documents\Egosoft\X4 Foundations\ folder.

Advanced Usage

Consider using a log analysis tool like glogg which can help you sort, filter, and find data in the logs.

@echo off
rem !!--- please change this to where your game is installed. do not add any spacing aroud the equals operator
rem !!--- set X4_EXE_PATH="Location of your X4.exe"
set X4_EXE_PATH="%PROGRAMFILES(X86)%\Steam\steamapps\common\X4 Foundations\X4.exe"
rem !!--- set the date and time for logfile year-month-day__hh-mm-ss
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
set datetime=%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2%__%datetime:~8,2%-%datetime:~10,2%-%datetime:~12,2%
echo "Date & Time test = %datetime% year-month-day__hh-mm-ss"
rem stores a value like `x4-game-2018-12-10__11-04-11.log` - to be passed in -logfile
set LOG_FILE_NAME=x4-game-%datetime%.log
rem stores a value like `x4-script-2018-12-10__11-04-11.log` - to be passed in -scriptlogfile
set SCRIPT_LOG_FILE_NAME=x4-script-%datetime%.log
set "exec=%X4_EXE_PATH% -logfile %LOG_FILE_NAME% -scriptlogfile %SCRIPT_LOG_FILE_NAME%"
rem execution phase, first we log out the command, if any of the variables are blank, make sure you dont have whitespace around any of the variables
echo "Executing %X4_EXE_PATH% -debug all -logfile %LOG_FILE_NAME% -scriptlogfile %SCRIPT_LOG_FILE_NAME%"
start "" %X4_EXE_PATH% -showfps -debug all -logfile %LOG_FILE_NAME% -scriptlogfile %SCRIPT_LOG_FILE_NAME%

This comment has been minimized.

Copy link
Owner Author

@MattMcFarland MattMcFarland commented Dec 13, 2018

Big thanks to a mysterious person on x4 forums for sharing with me the l10n issue 👍


This comment has been minimized.

Copy link

@jan12342203 jan12342203 commented Jan 30, 2019

good work... but it isn't scriptlogfile it is scriptlogfiles :-)
start "" %X4_EXE_PATH% -showfps -debug all -logfile %LOG_FILE_NAME% -scriptlogfiles <---- %SCRIPT_LOG_FILE_NAME%


This comment has been minimized.

Copy link

@Patola Patola commented May 26, 2019

What are the debug outputs, besides "all"?


This comment has been minimized.

Copy link

@UniTrader UniTrader commented Jul 7, 2019


Scriptlogfiles are named and put in a subfolder within the Script. The Command is
<debug_to_file name="'FILENAME'" directory="'DIRECTORYNAME'" text="'Line to be logged'"/>
you can omit the Directory to put it directly in the logs, but its not a single file you can name via startup parameter, its possibly lots of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment