Unity allows you to log variety of messages into the Console window by using Debug.Log() function family. I don’t think that I need to convince anyone about how useful the logs are. However, did you know that when you’ve already built your application, you still are able to access your game logs?
Accessing logs from the editor
First things first. The Console window is not the only way to see the logs. Unity is constantly appending all the editor messages into a special text file. This file can be accessed by clicking on the small “hamburger” icon in your Console window and then by selecting Open Editor Log option.
The screenshot above is from Unity 4. For Unity 5 there will be two log options instead:
- Open Player Log
- Open Editor Log
Player Log will contain only logs that are normally created by the Unity player. This includes user (game developer) logs. The Editor Log on the other hand, is the group of logs logged by the Unity editor itself and the editor scripts. You may want to take a look at these if you want to check why your build is so damn big.
Accessing standalone logs
What about the logs of an already built game? You might not know that, but the Unity player is logging the standalone messages to output_log.txt file inside the _Data folder of your game. Just go where your game executable is and enter the _Data directory (its name depends of the name of your game).
Then inside you will find the output_log.txt file (there will be many other files too that you shouldn’t modify in any way).
For the Mac standalone situation is a little more complicated. All Unity games logs can be found in a single place and this is ~/Library/Logs/Unity/Player.log file. It may be a little tricky to access because the Library folder is not visible in the Finder by default. To access it easily, click once on your desktop (or open Finder), then choose Go/Go To Folder from the main menu or use the ⇧⌘G shortcut.
Then enter the folder location.
And you’re there!
Accessing iOS logs
The Unity iOS player works a little different than the standalone player. It does not log the messages to a file but you are still able to access it. All you need to do is to launch your game from XCode. After a while you will see log messages from your game.
Accessing Android logs
The Unity Android player works very similar to iOS player.
Android Device Monitor allows you to connect to your Android device and display its logs (LogCat window). Be aware that LogCat by default will produce logs from all the applications running on your device (even those that are running in the background) and operating system itself. Therefore, you may find it difficult to separate your game logs from the rest. To help you with that, you may create the LogCat filters. The Unity player messages are logged with Unity tag, so it will be quite easy to create an adequate filter.
You can find a page in Unity manual that contains paths and quick instructions on how to access logs on different platforms. If you consider this information useful, add it to your bookmarks for the future use.