x


How do I write to the console?

I'm writing some C# scripts for a Windows Standalone application in Unity. I'd like to print some debug messages to the Unity console, but I can't figure out how. I've read that I should be able to do this using print(), Debug.Log, or System.Console.WriteLine(), but the first two just output to the log file, not the console, and the last doesn't appear to do anything at all.

I'm new to both Unity and C#, so don't hesitate to mention potential solutions that should be obvious enough for me to already have tried them :)

For the consolation prize...

As a workaround, I've been using BareTail to watch the log file, but it kinda sucks because Unity outputs the whole stack trace every time I print(). Any way for me to suppress that?

more ▼

asked Aug 17 '10 at 10:05 PM

duggulous gravatar image

duggulous
148 3 4 11

(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest

It seems that the key piece of information I was missing was that Debug.Log writes to the console only when you run the game from within unity by pressing the "play" button above the game view.

I was running my game by pressing Ctrl-B, or pressing "Build & Run" in the Build Settings window. In that case, it will only output to the log file.

more ▼

answered Aug 26 '10 at 09:18 PM

duggulous gravatar image

duggulous
148 3 4 11

Where is the log file?

Apr 18 '13 at 04:56 PM hyliandanny

They are here

or here

Apr 18 '13 at 06:13 PM Bunny83

They are here

or here

Is there really a need to be a jerk? Your suggestions are how I ended up here. Please consider consolidating useful information to a single location in the future instead of endorsing a distributed mess of incomplete steps.

For future searchers: the following link describes the location of the log file on multiple platforms. Worked for me on a mac.

http://answers.unity3d.com/questions/9739/how-can-i-find-editor-log-file.html

Apr 18 '13 at 06:34 PM hyliandanny

Unity has created a helpful page for where to find the log files on all the different platforms. You can find that page here:

http://docs.unity3d.com/Documentation/Manual/LogFiles.html

Jun 18 '13 at 06:33 PM spolglase
(comments are locked)
10|3000 characters needed characters left

print is an alias for Debug.Log, which does appear in the Unity console. There's also Debug.LogWarning and Debug.LogError, which (strangely enough) print lines labeled as warning and error messages. The latter is particularly useful if you have Error Pause selected in the console.

more ▼

answered Aug 17 '10 at 10:28 PM

Eric5h5 gravatar image

Eric5h5
102k 49 165 620

I'm not getting any output in the Unity console when I call Debug.Log

Aug 17 '10 at 10:54 PM duggulous

Then your code probably isn't getting called.

Aug 18 '10 at 01:00 AM Tetrad

The output IS showing up in the log file, so I know the code is being called.

Aug 18 '10 at 02:10 PM duggulous

If is showing in log file and not showing in console you might have filters turned on (top right of console)

Jan 16 at 04:02 PM mikesx
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x155
x86

asked: Aug 17 '10 at 10:05 PM

Seen: 57064 times

Last Updated: Jan 16 at 04:02 PM