What log source is used by logcat (with default settings: adb shell logcat). Are dmesg logs included in logcat's output? If not, what's the difference between dmesg logs and logcat logs?
According to the source code https://github.com/android/platform_system_core/blob/master/liblog/logd_write.c Log.d(String tag, String message) writes directly to /dev/log/main.
You can write there like this adb shell echo "Hello world" >> /dev/log/main
But dmesg prints the contents of the kernel's ring buffer. So dmesg will print only what system writes to kernel log, logcat will output only android app's logs.
LOGCAT-- This is used in Android , to see the different messages written by the activity managers inside the Android , u see android also uses the linux kernel , but what it does is, once the kernel boots ( the hardware initialization /probing has been taken care of) , the android starts a process called init which parses the init.rc file which contains all the android system activities , i mean the basic processes for android to boot , in this init.rc file there's a process called zygote which starts the Dalvik Virtual Machine , and after that all the other activity managers , which will be used by the application to interact with the hardware . so its basically messages from the VM , for the application programmers to debug it .
logcat example
http://pastebin.com/bV1Vd6EQ
Dmesg- it is messages from the kernel , suppose u write a driver , it can be used as a tool for debugging drivers and other kernel code, most of them are driver messages its a good way of debugging , the kernel , driver etc..
dmesg example
http://pastebin.com/P4ja9PFi
Logcat is only for android and its not available in any other OS , both Logcat and dmesg is available on Android but not the vice versa for any linux distros .
regards,
zubraj
Related
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)
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.
Not quite clear what logcat can and cann't. Suppose my phone is connected to my local computer. Do:
c:> adb shell logcat > /data/tmp/logs/log.txt
log.txt file will be created on the android devie. After some time, phone crashes. How can I got the log.txt back from the device? Is there a way to directly output all the events (even kernel message such as dmesg does) on the device to my computer, instead of generating a log file on the device first, then pull it to the computer?
You Should use android-logging-log4j.jar
You can store all the log in .txt or .xml
For More details go through
https://code.google.com/p/android-logging-log4j/
You need to give path where you want to save your log. So can navigate to that path and can get the log file
Hope this help.
I have some question related to the Android Logcat, I am refering these questions to be in REAL DEVICE not the emulator:
I have a program which has a lot of Log.d (or other similar log functions), I did some google search and found that those logs will be output to a circular 64K buffer. My question is, where are those 64K buffer located? Is it located in RAM or file system? Will it be removed after my app exits?
I google and found that, the log will be output to a file called /dev/event (not sure), but I couldn't see any application-related logging inside, why? Only system-related log entries can be seen.
Does every app output its log to a different log file? Or are they all dumped into the same log file? In this case, how can we seperate the log?
If the logging buffer is 64K, how can we increase it? If we want to re-direct the log to a file which is on a sd card, how can we limit the file size (of course make it circular too)?
Going point by point:
(1) The log buffers are in RAM, in the kernel. Logging is handled by a kernel driver. On recent devices, the log buffer is much larger than 64KB. They are not lost when an application exits, but will not survive a device reboot.
(2) The device entries are in /dev/log, e.g. /dev/log/main for the main log, /dev/log/radio for the radio log, and /dev/log/events for the event log. The logs are stored in a format that is generally more compact than what you see in logcat, so reading them directly with something like cat may be confusing.
(3) All apps write to the same log devices. Each log message is tagged with the process ID and thread ID of the log writer, so you can separate them out that way. (logcat -v threadtime will show you the pid, tid, timestamp, and tag.)
(4) You would need to change a value in the driver to alter the size of the log. Again, recent devices have much larger log buffers, so this is probably not so useful. You can send the output to a file with logcat; if you want to do some sort of circular buffer you will need to capture the output of logcat and handle it yourself. (You could also read the log device directly, but I don't think the API is public. See the AOSP logcat sources.)
Recent versions of Android do not allow apps to read all entries in the log. Instead, apps may only read the entries that they themselves generated. This was done to allow bug reporting systems to capture the logs, while preventing wayward apps from "spying" on other apps. When you run logcat from adb shell, it runs as the shell user, which has permission to read all logs.
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.