There are several questions about the subject, however not one of them seems to address the particular problem I'm having.
I'm developing an app with Cordova/Ionic, and printing debugging info I was outputting with console.log() by using adb logcat CordovaLog:D *:S was working just fine until some updates. Now I can't seem to figure out how to properly filter logcat's output so I could only get the debugging info from my app.
Logging itself works. If I set no filters and redirect output to a file, I can see my debugging info among all the other debug messages, and it looks like this:
I/Web Console: Event triggered: device.ready:1
Logging to screen also works, but at a rate of approximately 100 lines per second. I've tried at least the following to filter output:
adb logcat -s "Web Console"
adb logcat "Web Console":V
adb logcat "Web Console":*
adb logcat -s Web
adb logcat Web:V
adb logcat "myApp":V
adb logcat myApp:V
adb logcat -s myApp
... and probably others I've already forgotten. They either print absolutely nothing, or absolutely everything from the system services.
I'm on Windows so I can't grep, and the device I'm debugging on is running Android 4.2.2 so I can't use GapDebug, and neither does it seem to be possible to access the device's log via chrome://inspect in Chrome.
I really, really would like to understand how filtering logcat's output works. I'm not willing to log everything to a file and then shift through that.
It seems that logcat can not properly parse tag names with whitespaces. So instead I suggest using grep on the device:
adb shell "logcat | grep 'Web Console'"
Alternatively when runing adb on linux or unix based os/git bash:
adb logcat | grep 'Web Console'
What works for me in 2019:
adb -d logcat chromium:I *:S
The -d indicating a physical device in my case. If all else fails just dump the results of adb logcat into a text file and do a search for "CONSOLE", that will give you the provider for your logcat filter. It seems this changes over time, and depending on your particular dev environment.
While you can use grep under Linux/Unix, findstr might be your choice under Windows:
adb logcat | findstr /C:"Web Console"
If you prefer to use grep under Windows, you can get it from
http://gnuwin32.sourceforge.net/packages/grep.htm.
Related
I have a strange problem after Oreo update - 'adb logcat' stopped working.
Note that device is properly connected - I can debug, I can view logs in Android Studio, even I can start adb shell and do logcat but no direct logcat out from the adb command.
So in short,
# adb logcat
Absolutely no output. However, following works (logcat from the adb shell)
# adb shell
logcat
Any idea?
try these steps (even though your logcat is open)
in android studio go to
View->Tool Windows->Logcat
see if it works
This question already has answers here:
adb shell Logcat with Package Name
(4 answers)
Closed 5 years ago.
I'm using adb logcat in the **\Android\sdk\platform-tools directory. I'd like to filter out the log messages by package name, so I can see just the log messages that come from my app. I've gotten as far as using
adb logcat *:E
which only displays the messages on the error level. Then I tried to filter out things by tags (so if there is no other way to filter things out by app/package name, I thought I'd just put a name in the tag to filter those), but running something like
adb logcat TAG:E
doesn't seem to filter out anything. I've had a look at the Android Studio user guide, but that didn't get me any further, either.
I'm using Android Studio, and I'd like to see the log of my app after the app crashed when I'm really using it and not just debugging in Android Studio.
Thanks in advance for any help or tips.
You can filter adb logcat output by process ID by using the --pid=<pid> option.
To get the process ID for your app, you can run adb shell ps | FINDSTR <app name> (for Windows) or adb shell ps | grep <app name> (for *nix and OSX) while the app is still running.
Since you are trying to get logcat output after the app has crashed, the ps command won't work. You can generally filter logcat output by running adb logcat | FINDSTR <search term> (for Windows) or adb logcat | grep <search term> (for *nix and OSX).
This way, you can still assign meaningful tags to your debug messages and further filter on them.
Hope this helps!
So Android Studio has a very useful Android Monitor that shows logs specific to my application and everything going on with it; I've tried a few hours to get a logcat from the adb command line that is similar but I'm not getting even close. Specifically I just want the logs from my application, Info level or better. Thank you for whatever help you can provide.
In other words: what parameters can I add to adb logcat in order to see logs similar to what you would see inside the Android Studio, Android Monitor view.
With this command you can have the same log style as is in Android studio, in a file.
One shot:
adb logcat -vD -vthreadtime -vUTC -d > yourfile.txt
Continuous:
adb logcat -vD -vthreadtime -vUTC > yourfile.txt
Try this:
adb shell "logcat | grep filter"
"filter" could be "you app pid)", or "the TAG".
Like this:
adb shell "logcat | grep 12345)"
adb shell "logcat | grep com.xxx.yyy"
If using Windows,you can do this:
adb logcat | findstr filter
When you connect your device with pc you can see adb log by android monitor in android studio or command like as adb logcat -v. When you close your app, the connection with your app have closed. You have two way to check log:
in logcat window select No Filter or Edit Filter configuration
Using keystring, Example Samsung device using *#9900#
Hi i want to get the application specific log in the command prompt of windows i tried this
Filter LogCat to get only the messages from My Application in Android?
adb -d logcat com.mycompanyname.demoapp:I *:S
But didn't work for me huge log was printing which was very difficult for me to find my app specific log.
I want to print my app specific log in command prompt.
The string that logcat uses for filtering by is not a package name but a TAG.
So logcat com.mycompanyname.demoapp:* won't work unless the package was compiled with its name used as the logging tag.
There is a workaround you can use with Android 7.0+ devices:
adb shell "logcat --pid=$(pidof -s com.mycompanyname.demoapp)"
This command finds out the process ID for the package and then uses it for logcat filtering.
I want to write all logs displayed in logcat into a file when my application crashes (forced close) or else also.Is there ane way to get Logs programatically ? or is there ane way to know when my application crashed?
I dont want to use "adb logcat " command. Plz help me out
Have a look at this microlog4android
and also go through this question too How do you save an Android application log to a file on a physical device?
Copied "Lars Blumberg" answer for your quick reference:
$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start
Refer for more info: Viewing stdout and stderr
If you want write your own Log function, see this answer Android Writing Logs to text File