I want to dump all logs out to test a long usage of my app, maybe 2-3 days, but the logs seem to be cleared out while running after a long time.
How can I keep the logs?
I do not want to connect my device with eclipse all the day, I want the log just keep for me, like store it in the sd card for further check.
I had same requirement for my application. By default there is logcat process that tracks logs up to around 64kb (depends on device).
You can start your own logcat process using adb shell with some custom arguments. For example:
adb shell logcat -f /mnt/sdcard/large.log -r 100 -n 10
This will save up to 1mb of logs evenly distributed among 10 files (large.log, large.log.0, larget.log.1, etc.);
The next step is to launch logcat from your application:
String [] args = new String[] { Logcat, "-v", "threadtime",
"-f", logFile.getAbsolutePath(),
"-r", Integer.toString(sizePerFile),
"-n", Integer.toString(rotationCount),
"*:"+filter};
Runtime.getRuntime().exec(args);
So now your app may start saving logs. But you should be careful not to enable this in your production versions of application (or at least make this opt-in feature).
Instead of using the eclipse log use the apps like 'log viewer'. I think that app can solve your issue. I think the log will remain until you clear the log manually in 'log viewer'. I just downloaded it today morning and still has the logs of actions I performed just after I switched on the device.
Did you try dumping the log to a file?
adb logcat > log.txt
Related
In my app, I am using Timber as a logger. I am accessing the logs from the terminal via adb using this isntruction:
./adb logcat com.company.my_app:D
I do get the logs but the issue is that I am getting a crazy amount of noise from the OS (ie SurfaceFlinger , GraphicBuffer, vndksupport) which make the logs harder to read.
Is there a way to filter the logs like in Android Studio and just get logs from my app. Thank you !
P.S. I have trie a few answers from here but none of them remove the noise.
What works best for me is to grep for the process ID which is displayed in every log line. In the example below 7098 is printed with every log line.
08-10 18:48:39.825 7098 7144 D NetworkModule: --> END POST
So this is the adb instruction used to get filtered logs:
adb logcat | grep -F "7098"
Note: the process ID is not static and it is going to change if app is hard-closed or device is restarted.
I don't know if it is the best solution, but it works in my case.
My app is a root app and I have access to root shell on android phone. My requirement is to write logcat output for one minute into a file and then send the file to server. My app handles the file sending part but I am having trouble with collecting the log for specified amount of time.! I do not see any option in logcat command to specify the time duration. Is there any other way.! The following are the limitations I have
Command needs to be executed only on android phone shell. Since the device is not with me I can not use a laptop to run/schedule the command.
Command has to run only specified amount of time. I looked at -d of logcat options but it gives me log for around 5 seconds which is not sufficient for me to look at crashes.
I can see there are 4877 messages in total in my logcat but when I select the "All messages" filter, nothing is there.
I have tried the following:
adb kill-server
adb start-server
Of course, I went to DDMS and select my 1 and only device (a real handset, not an emulator) but it didn't solve the problem.
I can certainly view logcat messages using adb logcat command but it's very difficult to see compared to logcat in ADT.
Restarting ADT does solve this problem but it's happening way too often and you all know restarting ADT takes time.
Note that the "All messages (no filters)" filter is only an example here. The same issue happens to the custom filters I've created as well.
It doesn't always update that value when you clear it or if they get pushed out of the buffer. As long as you don't tamper with ADB or manually clear it it the 'No Filter' option should stay full though.
How can I see timestamp in Logcat? Is there any application which shows me the log along with the timestamp? Also, how can I increase the size of the Log in andriod phone?
To get timestamps: logcat -v time
To run logcat on the device at a shell prompt: logcat
There are several free logcat viewers for Android. I've heard that aLogCat is pretty good.
EDIT
You can set your preferences in aLogCat to see the time.
Regarding your second question, I found an answer here:
The logs are held by a kernel device; the entries are in /dev/log.
The buffer is currently 64KB, and there is no way to change the size
on a production device.
The easiest way to keep more of the log is to run "logcat" and send
the output to a file. logcat runs on the device, so you could run it
there and redirect it to (say) /sdcard/log.txt.
I am developing an application and during my testing on a real device I have found that it will crash and cause the phone to reboot (worrying I know...)
Is there any way I retrieve the logcat from before the phone rebooted as the logcat seems to reset when the phone boots up.
Thanks in advance.
Use http://code.google.com/p/acra/, which is a great lib to send crash reports to a google form incl. stack trace. I use it in my app and works nicely. Let me know if you have any difficulties implementing it.
Read the http://code.google.com/p/acra/wiki/ACRAHowTo, it's easy to setup.
From slashfoo's blog, (check the logcat page for exact syntax)
hook up your computer to start off the logcat process in the background.
adb shell nohup logcat -f /dev/[your sdcard] -n60 -r3600
Although it means logcat will be saved to the sdcard but every time you reboot, you must perform the procedure again.
Easiest way:
Get aLogrec from Market for free.
This app saves the logs to sdcard.
Use the alogrec program. It writes the log to the SD card, and will automatically resume after rebooting.
Updating for 2019, Fabric, which was purchased by Google, does an excellent job of remote logging app crashes. Integration into the app was simple, and it is free (at least at whatever level I'm using it).
It has been extremely valuable to finding defects in my apps.
https://www.fabric.io
Try to open a terminal/command prompt and issue this in it :
adb -d logcat
This should dump you a live version of the logcat you could read to find the problem