I'm using http://crest.codegist.org/ to communicate with server and I want to log responses and requests with android LogCat.
How can I configure CRest (or System) to do this?
Thanks
You can do it in two ways:
execute a command on your connected device:
MBP:~ roman$adb shell setprop log.tag.CodeGist VERBOSE
set the same property programmatically using the System.setProperty() method
Related
When I watch android source code, I found
adb shell setprop log.tag.CAM2PORT_ VERBOSE
This can output log in logcat. I want to know how to make all log tag output even if it is verbose.
I have tried
adb shell setprop log.tag.* VERBOSE #It's not work
Thanks for your help
You must set every tag you want to log. Regex like log.tag.* won't work.
Like you said, not optimal if you are using different tags in your app.
You can try to use the local.prop file and define all your tags, probably easier than using adb shell setprop for every tag every time you want to enable logging.
You can also create a local.prop file that with the following in it:
'log.tag.=' and place that in /data/local.prop.
https://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String,%20int)
In order to set a global minimum log level there is no need to configure tags individually. Just run
adb shell setprop persist.log.tag V
to enable all logs with any tag. Any supported Android priority can be set, so also DEBUG, INFO and others. The names can be specified in full, but only the first character is relevant. You can find more details here: https://medium.com/#mike_87757/set-android-minimum-log-level-globally-for-all-tags-4b1cbc1dc71f
I'm working on a non phone device that run Android 2.3.3. We have a custom Android version (with some additionnal driver) and my application has "system" privileges since we build our apps with the same key used to build android.
I had unlocked full Android API (including com.android.internal.*) following this post : https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/.
I deleted the Phone.apk from the device to ensure that no process is using rild.
I can instanciate a GSMPhone from my app, but after, I'm unable to execute any commands like supplyPin or getImei. I always have the same error :
CommandException: RADIO_NOT_AVAILABLE.
I'm really stuck here, any help would be precious.
CommandException: RADIO_NOT_AVAILABLE indicates that the rild socket is not opened. In other words, the rild service is not attached to the underlying basebane/modem you are using.
Run ps in adb shell to check if rild service is in the list. If it is in the list, run ls -l /dev/tty* and check if the modem device attached with the Android platform exists here or not. If it does not exist, it means that the Kernel is unable to enumerate your modem device and you need to add support in kernel for it. If it exists, run adb logcat -b radio and check the radio logs output which would really be helpful to diagnose the issue further.
adb shell ps | grep rild to check if RILD is in runing.
Since you can access all the api, do some initialization like PhoneApp do in Phone application OnCreate(mostly like setting params to modem, set radio power which will power on/off the modem, etc)
I wish to reset an android device programmatically using :
adb shell
recovery --wipe_data
1. What is the easiest way to do this ?
2. Will it require root/superuser access ?
For running shell commands you can use Runtime class. For more information check the documentation
For example:
Runtime.getRuntime().exec("commands_here");
Is it possible to use the android api functions from the adb? If its possible, what is the syntax to do so?
For example I'd like to call the "DATA_CONNECTED" function from android.telephony and get its return value. Link: http://developer.android.com/reference/android/telephony/TelephonyManager.html#CALL_STATE_OFFHOOK
There is no DATA_CONNECTED function in Android TelephonyManager. It is a 0x00000002 constant - one of possible response codes to the getDataState() function.
The way you call getDataState() from adb shell is:
service call phone 32
Update: if your phone runs anything older than jb-mr2, the command should be:
service call phone 31
P.S. just finished my write-up on Calling Android services from ADB shell - it includes a small bash script to look up calling codes for any service/method for a specific device.
I am using a Samsung Galaxy S3 device for development and my app is using the camera.
In the logcat, there is an output made by the native system with the tag Camera-JNI that is written to logcat like 20 times per second, causing the logcat to clean the oldest entries very fast.
Is it possible to disable logs from already installed apps or system logs to prevent this? Filters doesn't work, as the logcat is still filled and lines are still being clared.
Thank you.
EDIT
The documentation says this:
You can change the default level by setting a system property: setprop log.tag.<YOUR_LOG_TAG> <LEVEL>. You can also create a local.prop file that with the following in it:
log.tag.<YOUR_LOG_TAG>=<LEVEL> and place that in /data/local.prop.
EDIT 2
I already did this (rooting the device, pushing the local.prop file to /data and rebooting) but the tag is still appearing
I can see the following by examining the android source code (2.3.x):
Executing
shell setprop log.tag.XYZ
will not work here (frameworks/base/core/jni/android_hardware_Camera.cpp), as logging is being done using the LOGV() macro. This method of logging does not use properties to detect if some component wishes to disable logging. That is as far as I am able to trace the calls trough the android code.
So using setprop(...) will not work for disabling logging from an android system component but it should work when the logs come from user apps etc. written in Java which use base/core/java/android/util/Log.java and frameworks/base/core/jni/android_util_Log.cpp to log. My guess is that android_util_Log_isLoggable() is what is being used to filter.
IMHO I see no other alternative than building from source for your device and disabling the LOGV macros in the camera code you are using.
You can try something like adb shell setprop log.tag.Camera-JNI ERROR. If it doesn't work simply filter the log or dump it to a file and use grep to find the lines you are interested or filter out the camera with grep -v Camera-JNI.
If you want to see specific tags use:
logcat -s YourTag:* SecondTag:* ThirdTag:* ...
You can also use adb logcat
Just specify <TAG>:* as many times as you want to filter the tags you need.
Example: adb logcat -s AndroidRuntime:* MyApp:* filters AndroidRuntime and MyApp tags. So you see all uncaught exceptions (crashes) and also all logs of your application.