Skip to content

Instantly share code, notes, and snippets.

@rsaunders100
Created September 7, 2011 15:42
Show Gist options
  • Save rsaunders100/1200924 to your computer and use it in GitHub Desktop.
Save rsaunders100/1200924 to your computer and use it in GitHub Desktop.
(Android) Prints a stack trace of an exception with a given tag.
private static void printStackTraceWithTag(Exception e, String tag)
{
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
Log.e(tag,stringWriter.toString());
}
public void exampleUsage()
{
try
{
// ....
}
catch (Exception exception)
{
printStackTraceWithTag(exception, TAG);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment