0

I need to log information relative to dalvikvm, i can see them using the LogCat window but i want to do is to save a particular information into a file.

12-29 10:34:47.881: D/dalvikvm(7634): GC_FOR_ALLOC freed 23794K, 76% free 11573K/47148K, paused 14ms, total 14ms
12-29 10:34:47.891: I/dalvikvm-heap(7634): Grow heap (frag case) to 34.952MB for 23970832-byte allocation

I need to log this so i can say to my customer to save a bitmap it uses 23794k in 14ms ....

But i have no ideas on how to do this.

Thanks, i know this is something special.

Sufiyan Ghori
  • 18,164
  • 14
  • 82
  • 110
user2335528
  • 161
  • 1
  • 3
  • 13
  • You can see the logcat output for your own app by running the "logcat" command on the device, from your app, and capturing stdout. – fadden Dec 29 '14 at 16:09
  • i want my app be able to save this an .txt file for example – user2335528 Dec 29 '14 at 16:13
  • See e.g. http://stackoverflow.com/questions/3359692/how-to-redirect-my-log-output-from-logcat-to-the-sd-card-on-an-android-device or http://stackoverflow.com/questions/27678829/android-clear-log-programmatically – fadden Dec 29 '14 at 16:16
  • @user2335528 please mark an answer as correct if it helps you, don't just abondon your question. – Sufiyan Ghori Jan 06 '15 at 10:27

1 Answers1

0

You can use logcat -f <filename> to save your logs in a file.

also make sure that you provide a correct external storage path for a <filename>, you can get the full path of your SD card using, Environment.getExternalStorageDirectory().getAbsolutePath().

Example,

String sdCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
String fileName = "logs.txt";
String path = sdCard + fileName;

and from this question,

in order to pass arguments to the logcat program, you should pass the exec method an array of strings (and not one string):

Community
  • 1
  • 1
Sufiyan Ghori
  • 18,164
  • 14
  • 82
  • 110