Java / Android: How to display in StackTrace Log

13

How can I display the entire exception error code (FullStackTrace) in the Android Log?

try {
    //CODE
}catch (Exception e){
    Log.e(TAG,e.getStackTrace());
}   
    
asked by anonymous 18.12.2013 / 22:08

3 answers

14

I found it a very practical way, that I honestly did not know it could be done that way.

try {
    //CODE
}catch (Exception e){
    Log.e(TAG, "Seu erro: ", e);    
}
    
18.12.2013 / 22:21
2

You can use it as follows:

try {
  //CODE
} catch (Exception e) {

  Log.e(TAG, "log de erro: ", e.getMessage());    
  Log.v(TAG, "log de verbose: ", e.getMessage());    
  Log.d(TAG, "log de debug: ", e.getMessage());    
  Log.i(TAG, "log de info: ", e.getMessage());    
  Log.w(TAG, "log de alerta: ", e.getMessage());  
}

or

Log.e(TAG, "log de erro: ",new RuntimeException("TAG meu erro"));    
    
19.12.2013 / 02:00
2

I use this way:

Log.e("TAG", Log.getStackTraceString(e));
    
09.01.2014 / 01:57