Write Exception Stack to Log : Log « Core Class « Android






Write Exception Stack to Log

    
//package org.alldroid.forum.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;

import android.util.Log;

public class ExceptionHelper {
  public static void WriteStack ( String tag, Exception ex ) {
    final Writer result = new StringWriter ();
    final PrintWriter printWriter = new PrintWriter ( result );
    ex.printStackTrace ( printWriter );
    String stacktrace = result.toString ();
    printWriter.close ();

    Log.e ( tag, stacktrace );
  }
}

   
    
    
    
  








Related examples in the same category

1.Use log
2.Log Utility
3.Log events
4.Log your action
5.Write an activity that looks like a pop-up dialog with a custom theme using a different text color.
6.Responsible for delegating calls to the Android logging system.
7.Dynamically defined), space efficient event logging to help instrument code for large scale stability and performance monitoring.
8.Logger and Logger Listener
9.Log Exception trace
10.Log a list of objects
11.Utility log tool
12.Debug Util