0

I installed the .apk file in the device then run that application at this time suppose i am getting any exception then application will be crash. At this time i want to see that exception in the device without using Eclipse Logcat. It means i want send that exception to file(means some path in the device like sdcard/downloads/a.txt)in the device using Log.

Generally some applications are working properly in the emulator but in case of device we got some exceptions. so thats why i want see that particular exception in the device using Log.

Is it possible? How can i implement this? can anybody help me.

Myapplication classs:

package com.ibkr.roadbrake;
import org.acra.*;
import org.acra.annotation.*;
import android.app.Application;
import android.os.Bundle;

@ReportsCrashes(formKey = "dDJ5VFhURVNHakhSa3hfTndteFd6Smc6MQ") 

public class MyApplication extends Application 
{
  @Override

  public void onCreate() 
      {

           // The following line triggers the initialization of ACRA

        ACRA.init(this);

        super.onCreate();
    }

 public Bundle getCrashResources()
     {
     Bundle result = new Bundle();
     String RES_TOAST_TEXT = null;
     result.putInt(RES_TOAST_TEXT, R.string.crash_toast_text);
     return result;
 }

}

thanks

Aman Alam
  • 11,231
  • 7
  • 46
  • 81
naresh
  • 10,332
  • 25
  • 81
  • 124
  • See my post here: http://stackoverflow.com/questions/6757179/how-to-write-exception-in-log-file-using-android/6757247#6757247 – chubbsondubs Jul 27 '11 at 14:50
  • You could use [ACRA](http://code.google.com/p/acra/). Check my answer on this [post](http://stackoverflow.com/questions/6808018/capturing-and-sending-logcat-output-by-email-or-to-server/6808082#6808082) – Ovidiu Latcu Jul 27 '11 at 14:36
  • How to put Toast in MyApplication class.it is not showing the toast message. My code is added above please refer. – naresh Jul 28 '11 at 10:47
  • When do you want do display the Toast ? – Ovidiu Latcu Jul 28 '11 at 11:52

1 Answers1

0

Log4j or slf4j can also be used as logging frameworks in Android together with logcat. See the project android-logging-log4j and log4j support in Android. Configuring logging to a (rotating) file(s) is very easy.

 static {
    final LogConfigurator logConfigurator = new LogConfigurator();

    logConfigurator.setFileName(Environment.getExternalStorageDirectory() + "myapp.log");
    logConfigurator.setRootLevel(Level.DEBUG);
    // Set log level of a specific logger
    logConfigurator.setLevel("org.apache", Level.ERROR);
    logConfigurator.configure();
}
Community
  • 1
  • 1
Rolf Kulemann
  • 213
  • 2
  • 6