- Home /
Timestamp on Console?
Is it possible to get timestamps to show on the Unity IDE console?
Answer by relser99 · Aug 31, 2018 at 03:30 AM
I know this question is nearly 8 years old now, but since it's the top Google result for "unity console timestamp", it seems worth mentioning: the Unity console does in fact offer timestamps on log messages as a built-in feature.
To get them, simply open the Console tab's options menu (click the "triple-bar" options button at its top-right corner) and select the Show Timestamp option. The timestamp is only precise to the second, so if you need e.g. milliseconds it looks like you still need to roll your own timestamp.
Thank you. I had these timestamps at school, but not at home. I was really confused and couldn't find an answer anywhere. I was like "meh I'm sure nobody answered about this here, this is from 2010!"... I'm glad I was wrong :)
Answer by jonas-echterhoff · Dec 13, 2010 at 11:46 AM
The built-in console does not track timestamps. However, you can hook into debug logging by using Application.RegisterLogCallback. From there you could write the log messages with a timestamp to a file for example.
Duck's suggestion might be more convenient, though, because you can layer it on top of the Unity console window - but this way, you can get timestamps for messages logged by the engine itself as well.
Answer by habitoti · Feb 01, 2014 at 04:12 PM
Checkout this for a complete solution: http://rombosblog.wordpress.com/2014/02/01/unity-debug-log-console-messages-with-timestamp/
Answer by salat · Jul 28, 2013 at 07:07 AM
just add this to some .cs file:
public class Debug
{
public static void Log(object obj)
{
UnityEngine.Debug.Log( System.DateTime.Now.ToLongTimeString() + " : " + obj );
}
}
no need to attach to gameobject and no need to modify existing code. note: this will hide default unity Debug class and if you need other methods you might want to add them as well samely
Answer by duck · Dec 13, 2010 at 11:30 AM
No, Unity doesn't have this feature built-in. I had this requirement myself too, and I ended up writing my own "Debug" class named slightly differently (called "DebugX"), which adds timestamps to everything written.
While I was writing it, I also added the feature of writing lines to a text file within my assets folder, so I could easily see the debug lines without the additional stack trace data, making it easier to read. This might be a useful idea for you too!
Good luck!
Your answer
Follow this Question
Related Questions
Print to console 2 Answers
Monospace Font In Console 2 Answers
Is there any way to view the console in a build? 7 Answers
Method not found: 'UnityEngine.Application.Loadlevel'? 0 Answers