Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by idbrii · Mar 23, 2018 at 10:18 PM · fileloglogging

How do I find the player log file from code?

I want to write a script to upload logfiles with a bugreport. How do I find the logfile? (For production, so no editor logs.)

The documentation gives these paths:

  • macOS ~/Library/Logs/Unity/Player.log

  • Linux ~/.config/unity3d/CompanyName/ProductName/Player.log

  • Windows Unity 5.6 EXECNAME_Data\output_log.txt

  • Windows Unity 2017+ C:\Users\username\AppData\LocalLow\CompanyName\ProductName\output_log.txt

How do I translate these paths into code?

CommandLineArguments docs has an entry for a -logFile option:

Specify where the Editor or Windows/Linux/OSX standalone log file are written.

If that's used, is there a way to get a path to the log file?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by idbrii · Mar 23, 2018 at 10:42 PM

For code examples, I assume you have CombinePaths.

macOS

~/Library/Logs/Unity/Player.log

Straightforward: just use that path.

Linux

~/.config/unity3d/CompanyName/ProductName/Player.log

CompanyName/ProductName are values from Edit > Settings > Player. They're exposed in code:

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

.

Windows

Unity 2017+ C:\Users\username\AppData\LocalLow\CompanyName\ProductName\output_log.txt

On recent versions of Unity, this should work for Windows:

 var log_path = CombinePaths(Environment.GetEnvironmentVariable("AppData"), "..", "LocalLow", Application.companyName, Application.productName, "output_log.txt");

.

Unity 5.6 EXECNAME_Data\output_log.txt

But for 5.6, docs say:

On Windows, EXECNAME_Data is a folder next to the executable with your game.

According to how do i get the application path, you can base it off of dataPath:

 // Unity strips some characters from productName to make the exe name. I've
 // also seen it convert to lower case.
 var exe_basename = Application.productName.Replace(" ", "");
 var log_path = CombinePaths(Application.dataPath, "..", exe_basename +"_Data", "output_log.txt");

.

cmdline

For -logFile, I think you have to parse the System.Environment.GetCommandLineArgs.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Fattie · Aug 29, 2020 at 03:31 PM

It's now pretty easy to write a log file anywhere you want:



Just use:

 void OnEnable() { Application.logMessageReceived += Log;  }
 void OnDisable() { Application.logMessageReceived -= Log; }



Full example:



https://forum.unity.com/threads/player-log-file-location-changed-is-there-an-option-in-settings-somewhere-to-change-it-back.500955/#post-6257543



Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lindgrenfabian · Aug 30, 2020 at 01:54 PM 0
Share

This isn't very useful as it only supports Windows, I'd recommend @idbrii's answer above instead.

avatar image CyRaid lindgrenfabian · Feb 05, 2021 at 03:15 PM 0
Share

Specifically to windows because of the SpecialFolder.Desktop? It's the: void OnEnable() { Application.log$$anonymous$$essageReceived += Log; } void OnDisable() { Application.log$$anonymous$$essageReceived -= Log; } That's the important part. You can have log save wherever or print wherever, it's just an example. Change the path if you want to.

avatar image RedHillbilly · Apr 11 at 05:10 AM 0
Share

This should be the accepted answer, it's perfect

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Log file on iPad 1 Answer

Logging frameworks/libraries in C# 3 Answers

Don't overwrite output_log.txt between runs 1 Answer

How to get rid of "Development Build" watermark but still have stacktrace in output log 0 Answers

Console.WriteLine Redirect to file 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges