title: Debugging - game and system logs
The game log shows all of the output from the engine, native extensions and your game logic. The print() and pprint() commands can be used from your scripts and Lua modules to show information in the game log. You can use the functions in the dmLog
namespace to write to the game log from native extensions. The game log can be read from the editor, from a terminal window, using platform specific tools or from a log file.
System logs are generated by the operating system and it can provide additional information that can help you pinpoint a problem. The system logs can contain stack traces for crashes and low memory warnings.
::: important The game log will only show information in debug builds. The log will be completely empty in release builds. :::
When you run your game locally from the editor or connected to the mobile development app all of the output will be shown in the console pane of the editor:
When you run a Defold game from the terminal the log will show in the terminal window itself. On Windows and Linux you type the name of the executable in the terminal to start the game. On macOS you need to launch the engine from within the .app file:
$ > ./mygame.app/Contents/MacOS/mygame
Logs can be read using the developer tools provided by most browsers.
You can use the Android Debug Bridge (ADB) tool to view the game and system log.
Once installed and setup, connect your device with USB, open a terminal and run:
$ cd <path_to_android_sdk>/platform-tools/
$ adb logcat
The device will then dump all the output to the current terminal, along with any prints from the game.
If you want to see only Defold application outputs use this command:
$ cd <path_to_android_sdk>/platform-tools/
$ adb logcat -s defold
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
I/defold ( 6210): INFO:DLIB: SSDP started (ssdp://192.168.0.97:58089, http://0.0.0.0:38637)
I/defold ( 6210): INFO:ENGINE: Defold Engine 1.2.50 (8d1b912)
I/defold ( 6210): INFO:ENGINE: Loading data from:
I/defold ( 6210): INFO:ENGINE: Initialized sound device 'default'
I/defold ( 6210):
D/defold ( 6210): DEBUG:SCRIPT: Hello there, log!
...
You have multiple options to read game and system logs on iOS:
To launch the game and attach the debugger you will need a tool called ios-deploy. Install and debug your game by running the following in a terminal:
$ ios-deploy --debug --bundle <path_to_game.app> # NOTE: not the .ipa file
This will install the app on your device, start it and automatically attach a LLDB debugger to it. If you are new to LLDB, read Getting Started with LLDB.
If you enable the Write Log setting in game.project, any game output will be written to disk, to a file called "log.txt
". Here is how you extract the file if you run the game on device:
iOS : Connect your device to a computer with macOS and Xcode installed.
Open Xcode and go to Window ▸ Devices and Simulators.
Select your device in the list, then select the relevant app in the Installed Apps list.
Click the cog icon below the list and select Download Container....
Once the container has been extracted it will be shown in Finder. Right click the container and select Show Package Content. Locate the file "log.txt
", which should be located in "AppData/Documents/
".
Android(
: The ability to extract the "log.txt
" depends on OS version and manufacturer. Here is a short and simple step by step guide.