Unity logs

Find Editor and Player Log Files in Unity

In the Unity environment, two types of logs are commonly used: logs originating from the editor and logs from a built version of the game (Player Log). Each platform stores these logs in different locations:

Table of contents

Unity Editor Logs

Here is where the editor logs are stored:

“~” corresponds to the Home folder of your user:

PlatformPath
Windows%LOCALAPPDATA%\Unity\Editor\Editor.log
Linux~/.config/unity3d/Editor.log
Mac~/Library/Logs/Unity/Editor.log

You can also directly open the logs via: “Window” -> “General” -> “Console” and click on “Open Editor Log”.

Unity open Editor log

Player Logs

Here is where the game logs are stored in a build version (player log):

PlatformPath
Windows%USERPROFILE%\AppData\LocalLow\CompanyName\ProductName\Player.log
Linux~/.config/unity3d/CompanyName/ProductName/Player.log
Mac~/Library/Logs/Company Name/Product Name/Player.log
Universal Windows Platform%USERPROFILE%\AppData\Local\Packages\<productname>\TempState\UnityPlayer.log
WebGLIn browser console: WebGL Debug documentation
AndroidDirect access not possible: use Android Logcat
MacDirect access not possible: see Apple’s documentation

Check the documentation for other informations.

Real-Time Logs

This feature is very useful, especially during testing phases if you have a built-in bug reporting system.

Your system could directly integrate the logs into the bug report. Don’t forget to ask for user consent through a checkbox, for example:

Unity editor report bug

Report bug in one of my game

Windows


public void SendLog()
{
    // get PlayerLog
    var logPath = Path.Combine(Environment.GetEnvironmentVariable("AppData"), "..", "LocalLow", Application.companyName, Application.productName, "Player.log");

    // get PlayerPrevLog
    var preLogPath = Path.Combine(Environment.GetEnvironmentVariable("AppData"), "..", "LocalLow", Application.companyName, Application.productName, "Player-prev.log");
    
    // read if file exists
    if (File.Exists(logPath))
    {
        string logs = ReadShareFile(logPath);
    }
}

// Logs are shared file we can read it with this function
private string ReadShareFile(string path)
{
    using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    using (var textReader = new StreamReader(fileStream))
    {
        return textReader.ReadToEnd();
    }
}

Linux

var pathLinux = CombinePaths("~/.config/unity3d", Application.companyName, Application.productName, "Player.log");

Mac

var pathMac = CombinePaths("~/Library/Logs", Application.companyName, Application.productName, "Player.log");

For Android and iOS, direct log collection is not possible. Native code needs to be used. However, as an alternative, you can subscribe to a log message event and then store them: Application.logMessageReceived.

Or, you can create your own logging system, such as a Logger.

Original main illustration by Daniel Neiva Dan Neiva of Pixabay.

Leave a Reply

Your email address will not be published. Required fields are marked *