Game and system log

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 pintpoint a problem. The system logs can contain stack traces for crashes and low memory warnings.

The game log will only show information in debug builds. The log will be completely empty in release builds.

Reading the game log from the editor

When you run your game locally from the editor or connected to the mobile dev app all of the output will be shown in the console pane of the editor:

Editor 2

Reading the game log from the terminal

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

Reading game and system logs using platform specific tools

HTML5

Logs can be read using the developer tools provided by most browsers.

  • Chrome - Menu > More Tools > Developer Tools
  • Firefox - Tools > Web Developer > Web Console
  • Edge
  • Safari - Develop > Show JavaScript Console

Android

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

iOS

You can use the Console tool to read game and system log. You can use the LLDB debugger to attach to a game running on device. To debug a game it needs to be signed with a “Apple Developer Provisioning Profile” that include the device you want to debug on. Bundle the game from the editor and supply the provisioning profile in the bundle dialog (bundling for iOS is only available on macOS).

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.

Reading the game log from the log file

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

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: https://stackoverflow.com/a/48077004/129360

Did you spot an error or do you have a suggestion? Please let us know on GitHub!

GITHUB