Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Player log file location changed; is there an option in settings somewhere to change it back?

Discussion in 'Editor & General Support' started by Dreamback, Oct 20, 2017.

  1. Dreamback

    Dreamback

    Joined:
    Jul 29, 2016
    Posts:
    204
    In Unity 2017.2, in Windows the log file is now located in

    C:\Users\username\AppData\Local\CompanyName\ProductName\output_log.txt

    when it used to be in the Product_Data folder. And that makes sense for release builds, but is there an option to return this to the old location while testing? The problem is, if I make two builds of my game with different filenames or locations (a very common thing in testing), they now write their logs to the exact same place, overwriting each other. I see you can manually set a path with a command-line parameter, but that would be a real pain to have to do that every time I made a build with a new name.
     
  2. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    468
    it's now fairly easy to send
    all of the log file to somewhere else ...


    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class LogAnywhere : MonoBehaviour
    5. {
    6.     string filename = "";
    7.     void OnEnable() { Application.logMessageReceived += Log;  }
    8.     void OnDisable() { Application.logMessageReceived -= Log; }
    9.  
    10.     public void Log(string logString, string stackTrace, LogType type)
    11.     {
    12.         if (filename == "")
    13.         {
    14.             string d = System.Environment.GetFolderPath(
    15.               System.Environment.SpecialFolder.Desktop) + "/YOUR_LOGS";
    16.             System.IO.Directory.CreateDirectory(d);
    17.             filename = d + "/my_happy_log.txt";
    18.         }
    19.  
    20.         try {
    21.             System.IO.File.AppendAllText(filename, logString + "\n");
    22.         }
    23.         catch { }
    24.     }
    25. }
    26.  
    Fortunately it's that easy
     
unityunity