- Home /
Enable stack trace in non development builds
Hello everybody,
I have created my custom log handler, using RegisterLogCallback(). My intention is to be able to catch all errors, and send them to my server for logging.
Everything works perfectly as expected, with the exception of one thing:
The Stack Trace is empty when I create a build without the Development Build checkbox checked.
Now here is the weird part:
Development Build checked, building on iOS device - The result is ok (stack trace contains data).
Development Build unchecked, building on iOS simulator - The result is ok (stack trace contains data).
Development Build unchecked, building on iOS device - the result is NOT OK (stack trace is empty).
I would like to enable stack trace on my production build as well, so I can better understand what errors occur in production builds.
Can this be done? I mean, it does work in the simulator, so what reason is there for it not working on the device?
Thanks in advance.
Update:
Unity support asked me to open a bug report
I opened it (case 523472)
Unity QA said its not a bug, but "by design"
I sure wish this "by design" feature would let the developer choose if he wants traces to be sent or not on development builds.
Uhm sure, just check the development build checkbox... That's what it's good for.
I don't quite get your question. You turn off the development build and wonder why development tools don't work?
Are you serious with this comment?....
Don't you understand the value of getting trace from PRODUCTION builds?
Answer by yoyo · Aug 13, 2013 at 10:32 PM
Try getting the stack trace yourself, rather than relying on Unity to do it, something like this (C# example):
private void Awake()
{
Application.RegisterLogCallback(LogHandler);
}
private void LogHandler(string message, string stacktrace, LogType type)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace();
// Now use trace.ToString(), or extract the information you want.
}
For more information on the StackTrace class, see Microsoft's documentation on MSDN.
Thanks for this. Good to see that old questions still have hope.
Tested and working nicely. Big improvement for me in catching production errors.
Cool, glad it worked. Note that the System StackTrace class may not include file and line number information in a non-development build.
Yes, I noticed. Well, in fact in both development and non development I do not get the line number, but I do get file and method. Good enough for me. $$anonymous$$uch better than before in any case.
I tried that, but I'm only getting Application.CallLogCallback and my own LogHandler method in the stacktrace. Am I missing something?
You should see the entire trace. I am using this call, and it seems to get me the appropriate trace:
using System.Diagnostics;
string $$anonymous$$yStackTrace() {
StackTrace trace = new StackTrace(4, true);
return trace.ToString();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613092415im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to use Webgl Debug Symbols? 0 Answers
Less verbose Debug.Log ( Xcode ) 0 Answers
Can't find unity-remote-4 in AppStore 3 Answers
iOS. Jerks in first 15-20 seconds after starting scene 0 Answers