Is it possible to get old logs (such as logs of one hour or one day before) of an Android device?
I am asking this because sometimes testers encounter some errors. The Android developer says that the error is related to the device's hardware. To prove his claim, he has to show the error inside the logs. But he says that when attaching an Android device to his computer, he cannot see past logs.
I'm not sure how it was back then, but with current Android versions you can use adb logcat to get at older logs. On my device this is limited to the current boot, but I understand that on some devices older logs may be accessible.
adb logcat --help will have all the details (note that your device must be connected even for the help functionality), here's an example usage:
To get all the logs from today at 4PM:
adb logcat -d -T "2022-01-27 16:00:00.000"
Or:
adb logcat -d -T "01-27 16:00:00.000"
As Year may not be valid in some ADB versions, with message:
-T "2022-01-27 16:00:00.000" not in "%m-%d %H:%M:%S.%q" time format
You can't, but there are libraries like ACRA which will automatically send you detailed crash reports including the user LogCat if you want (disabled by default).
If you don't want to use a library, when an error occurs you can also write the content of the Logcat to a file that your testers can easily find (like in a log folder of the SD card). It shouldn't be very hard to implement.
I think there is no way you can access the past logs, unless you save them.
Ask your testers to save the Log the moment they see the issue.
With the logger buffer size option on the developer option, one could choose the logger size for each buffer. There are quite a several logger sizes available and they include 64k, 256k, 1M, 4M, and 16M. I recommend only increasing the buffer size for debugging purposes, as the logging area is a ring buffer, this helps to capture old logs to some extent once we encounter the glitch that we're looking out for.
Related
I have a situation:
1. Samsung 7 has a strange bug in my app.
2. This device is 10000 miles away from me.
What are the opportunities for debugging this device remotely.
When tester on the other side can do everything.
I tried adb tcpip <port>
but device ip can be only local(192.168.....)
The rude way is to get Android Studio there and install team viewer on the phone. It's not working every time.
And when we have 1 hour intersection it's difficult to support.
Is there any other way?
Have your user enable Developer Options on the device. You should already know how to do that.
See whether the device has Take Bug Report and/or Bug Report Shortcut settings. If you enabled Bug Report Shortcut a Take Bug Report option will appear when pressing/holding the power button.
Instruct your user to take a bug report -- either through Developer Options, or from the power menu -- as soon as your app crashes.
As for the APK you send to your user, make sure debugging is enabled, so you get all your log messages. If you obfuscate the APK, be sure you keep your mapping files handy.
If you have some idea of where the bug is happening, an option could be to set up something like http://www.acra.ch/ and send your tester a new apk.
This way when the bug is provoked, given you set up useful log events, you will receive information about the crash or bug. ACRA lets you include the LogCat as well, which is pretty useful.
There are several options:
-Build APK and send it to the phone. Install and check/try again.
-Create Android Virtual Device identical to the model located remotely, install Samsung Android firmware.
There is no clear solution about debugging out of local network.
You could try something like LogmeIn for Android - this way both devices will be in the same network.
Once done, just do usual adb connect ipadress If t refuses to do so first, try enabling ADB over WiFi option
I have an app installed on my device.
An app that I developed, but I haven't got the source code anymore.
Is it possible to attach log cat to this app?
yes you can, just enable usb debugging on your android device, and plug the device where you have the application installed on it, by that, you will see all the logs on logcat.
Depends if you've left logs in the code. If you did, the easiest method would be probably going into your Android Studio and checking you Android Monitor tab. You can switch devices / applications there.
If you don't have any logs and your question actually means you want to add some logs in, then I'm afraid you can't reliably do that.
I'm currently developing a small android app which communicates with a FTDI chip over USB so I can't use logcat to get the logs live. Unfortunatly the Android device is a Galaxy Tab 2 with Android 4.1.2 which I'm not allowed to root. That means adb-wireless won't work too. And because it's just a small app setting up a bugtracker system like ACRA seems a bit oversized.
Is there another way to get the logs of my app?
Many thanks
I can't think of any "live" logcat output, but you can view your Logcat Output (which is Buffered) via adb logcat. Test the things in your app you want to do or to get the Error you try to solve, then connect the USB to a Computer running adb and dump the Log.
More information for the logcat Command can be found here
You can make a utility function that opens an HTTP connection and writes to a web server.
This adds a little overhead to your application, but works fine to get log info.
Easy to implement, no rooting required!
Or you could write a little service that runs a web server that responds to requests with a dump on logcat (or a tail or logcat or something).
It might even be possible to write a shell script that uses curl or wget to do this (that is send get requests to a webserver in order to pass logcat output), but you might need to install them, which in turn you might need root for, so... maybe this wouldn't meet your needs.
I guess it might even be possible to create a network share on your workstation, mount it on your android device and just redirect logcat output to a file on the share. But I didn't try it - let me know if you do!
You could use apps like Logcat or others alike, which will give you the same output as your IDE Logcat console.
You can turn on the logging, do your stuff in your app, and return to the logcat app to check out the log, mail it to yourself etc.
I did a little bit more research and it seems that there's no possibility to read the logs easily without having root rights. You're able to read the logcat output using bugtracking libraries like ACRA in your Android app, but it's a lot more effort to include them and analyze the logs.
I'm going to develop on my own (rooted) tablet with adb-wireless now.
I can't figure out what is going on. I am using ANdroid Studio 1.6 and I have made sure I am set to "Verbose" and I have deleted all of my filters. However when I run an application on my device, I see almost no messages. Not absolutely nothing, but maybe a dozen I/D/E level messages from dalvik and the android runtime. NOthing from my application and certainly not enough messages that I would expect from a daily driver device that has a number of apps on it with online services.
I am so confused, I've looked in every corner of the Android Studio configuration and I can't see where I might be missing something. I KNOW that it is suppressing messages because when I use my on-device logcat reader, I see everything just as expected, and it's dramatically different from what AndroidStudio is showing.
Edit: going to terminal emulator on the device and starting log cat had the same effect (messages being hidden) so this must be on the device somewhere.
Tried logcat -c and checked ANDROID_LOG TAGS
Edit2: from terminal emulator if I just type log cat then I have the aforementioned problem. If I type su logcat however then I see everything. Why would I need superuser to view the full logcat?? How would I even instruct ddms to request superuser?
I am experiencing a strange issue.
I am trying to collect some logs from my android phone using logcollector or aLogcat. Everything works just fine for my Nexus S and moto Defy but when I am trying to capture and send a log from Galaxy S the output is very very short. It captures only last few seconds of phone's activity.
Does anybody know how can I fix this?
Regards, Peter
Many possible things can be occurring here. Another process could be clearing the logcat buffer periodically (logcat -c). Galaxy S could have also modified the default buffer size for its logs to be very small (so it is constantly rolling them over). Other than that, who knows what it could be. The best I can think is to enable USB debugging and seeing if you can run logcat yourself and see what you can see (adb logcat). If you can see the logs fine then it is the app otherwise the system does not allow log collection.
use pipeline to save logs in text file from command prompt
adb logcat > logs.txt