Java tutorial
//package com.java2s; public class Main { static public void saveCrashTrace(Throwable ex) { StackTraceElement[] elements = ex.getStackTrace(); StringBuilder builder = new StringBuilder(ex.getMessage()); for (StackTraceElement ele : elements) { builder.append('\n').append(ele.toString()); } android.util.Log.e("crash", builder.toString()); } }