3

How do i retrieve the error logs of my application from device (and send them over the internet to a server)?

2
  • 2
    to clarify - do you mean collect log entries (generated by your app) from other peoples' phones and send to your web server programmatically ? Commented Jan 24, 2011 at 5:44
  • Ideally, you could make a type of error handling class that is instantiates an object when an error is generated. Once the object is created, it connects and send that log to your webserver. Commented Jan 24, 2011 at 5:50

2 Answers 2

2

(Assuming you are using log framework from android.util.Log package.)

You can start "logcat" process with specific parameters from within your process. It will dump last 16k of logs (16k - is default for my phone, it can be different on other phones).

Here is an example of command line that dumps all logs: logcat -d -f /mnt/sdcard/log-dump.txt
Another example that dumps errors from all applications: logcat -d -f /mnt/sdcard/err-dump.txt *:e

You'll need to launch the process from within your application programatically. And then process log-dump.txt/err-dump.txt in the way you want.

You also may want to monitor logs longer then those default 16k can allow you. For this you'll need to start logcat without -d parameter. If this is done, logcat process will write logs to file for as long as you want. When you are done just kill logcat process.

In any case you can look & test manually logcat using adb logcat <params> from you computer.

Sign up to request clarification or add additional context in comments.

Comments

1

I think you need to implement the try_catch block.

try { } catch(Exception e) { Log.e("Exception found ",e.getMessage); // post the exception message to your server } 

This way you can send the error log messages to the server.

1 Comment

Unless the developer has a serious need for immediate error notifications, this could probably be reduced to once a day or less!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.