--- title: Debugging - game and system logs brief: This manual explains how to read game and system logs. --- # Game and system log The game log shows all of the output from the engine, native extensions and your game logic. The [print()](/ref/stable/base/#print:...) and [pprint()](/ref/stable/builtins/?q=pprint#pprint:v) 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](/ref/stable/dmLog/) 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. ::: ## Reading the game log from the editor When you run your game locally from the editor or connected to the [mobile development app](/manuals/dev-app) all of the output will be shown in the console pane of the editor: ![Editor 2](images/editor/editor2_overview.png) ## 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](https://developers.google.com/web/tools/chrome-devtools/console) - Menu > More Tools > Developer Tools * [Firefox](https://developer.mozilla.org/en-US/docs/Tools/Browser_Console) - Tools > Web Developer > Web Console * [Edge](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide/console) * [Safari](https://support.apple.com/guide/safari-developer/log-messages-with-the-console-dev4e7dedc90/mac) - Develop > Show JavaScript Console ### Android You can use the Android Debug Bridge (ADB) tool to view the game and system log. :[Android ADB](../shared/android-adb.md) Once installed and setup, connect your device with USB, open a terminal and run: ```txt $ cd /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: ```txt $ cd /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! ... ``` ### iOS You have multiple options to read game and system logs on iOS: 1. You can use the [Console tool](https://support.apple.com/guide/console/welcome/mac) to read game and system log. 2. 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](https://github.com/phonegap/ios-deploy). Install and debug your game by running the following in a terminal: ```txt $ ios-deploy --debug --bundle # 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](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-basics.html). ## 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](images/debugging/download_container.png) 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).