Register device to file

How to redirect logging to a device in a file?

My application freezes on the device, but works fine on the emulator - I want to see the recording on my device without sdk and its tools.

+6
java android logging
source share
5 answers

I found a great feature of Logcat. It can redirect output to a file using the -f command simple parameter. To use it, you can write a Logcat shell in your aLogcat application. Obviously, I did it :)

To use logcat in android, I wrote this code:

Process proc = null; try { proc = Runtime.getRuntime().exec(new String[] { "logcat", <!parametes_here!> }); mReader = new BufferedReader(new InputStreamReader(proc.getInputStream()), 1024); String line; while ((line = mReader.readLine()) != null) { if (line.length() == 0) { continue; } mHandler.sendMessage(mHandler.obtainMessage(Logcat.MSG_READ_LINE, line)); } } catch (IOException e) { Log.e(TAG, "Cannot start process", e); } finally { if (mReader != null) try { mReader.close(); } catch (IOException e) { Log.e(TAG, "Cannot close stream", e); } } 
+4
source share

Check out the Android Log Collector .

+5
source share
+3
source share

I am using the aLogCat application, downloaded for free from the Android market.

It works very well.

+1
source share

Logging structures such as log4j already provide features such as logging to a file. Using android-logging-log4j , you can log in to the rotation log file and logcat. Also see log4j support in Android .

0
source share

All Articles