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.

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.