Using Debug.Log on built projects?

HI,

How does a person use the Debug.Log on a project after it has been built?

I have a project (tutorial) I have been doing that works fine in the editor, but doesn’t work in the build (PC Standalone). https://forum.unity3d.com/threads/space-shooter-tutorial-q-a.313899/page-43

How does one begin to troubleshoot a situation like this if there is no console?

Thanks in advance.

Debug.Log works in builds normally. It only doesn’t if you disable it in the player settings.

–Eric

2 Likes

the console output in builds are put in a file named output.txt in your build’s Data directory.

9 Likes

It’s also worth noting that the Log file has a lot of clues that can help you out. If it’s a simple error you might not even need your own Debug statements.

2 Likes

Thanks everyone. I found the log files. A quick glance through showed a bunch of null references.

So questions;

  1. does the game rewrite the log every time I run the program, and
  2. what might be a common place to start looking when a game runs fine in editor, but not in build?

Thanks again for your time.

2 Likes

Well, something weird is happening. I put a Debug line in that should count the number of collisions and according to the Debug report the game only generates one collision, which is what is happening in the build, but for some reason the game keeps functioning in the editor with explosions and scoring and such, but never generating another collision.

Will need to further investigate, but I think I’m on the right track.

Thanks for listening.

Figured it out.

I noticed the explosions were building up in the hierarchy, so I added my own line to destroy the explosions. It wasn’t until a couple lessons later the instructor points out the explosions accumulating and says using the destroy wouldn’t work in this case and he used destroy by time.

Since my game was working in the editor (but giving an error) I just left it the way I had it. But the editor must be more forgiving, because it wouldn’t work in the build. After figuring out where the issue lie, I re-watched the tutorial, changed from my destroy line to the destroy by time and the build now works. Yay!

The instructor never did explain why we could destroy the bolt, asteroid, & ship with a basic destroy command, but not the explosion. Would be nice to know. I’m just glad I was able to figure it out.

I can’t tell you exactly why without seeing the scripts, but there are a couple of reasons why you would want to get tricky with Destroy.

  • You need to Destroy an object after a set period of time, so explosions after they have finished exploding and so on.
  • You need to Destroy an inactive object.
  • You want to reuse the object in some fashion.

Use GameLog:
https://github.com/Kiarash-Parvizi/GameLog

Its free and easy to use :wink:

@Game_Changer2100 : I did as the instructions say. integration worked and I added the log entries in the scripts. Where do I find the logs?
From the instructions (“High-Performance Portable Log Window for unity”) I would expect something like an additional window, or a subwindow in game, but there is none. could you plz add some more info what to expect, and how to get hands on?
(Using untiy 2019.2.17.f1)
thx

1 Like

How To - Capturing Device Logs on Android and
How To - Capturing Device Logs on iOS

I dont see any logs for my windows build? where do they go?

Go here, and scroll down to “Player”

You can also force the log file to a specific path/filename with the -logFile command line argument
https://docs.unity3d.com/Manual/CommandLineArguments.html

1 Like

thanks mate, found the log eventually at C:\Users\username\AppData\LocalLow\company\Game

4 Likes

Somehow this log doesnt work anymore, it is created but I dont see my own entries. Just tons of error and stack traces. My game has a main menu to start game and it should print to log while thats showing but it doesnt. How to get a proper log of things we sent to Debug.log?

2 Likes

I’m experiencing the same issue. Lots of info, but no Debug.Log.

Make sure you havent done something like
Debug.unityLogger.logEnabled = false;