I observed that when i use Logcat with Eclipse with ADT for Android, I get messages from many other applications as well. Is there a way to filter this and show only messages from my own application only.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
This is obviously a question aimed at usage of Logcat from outside of the developer device, however if you want to display Logcat output on the device (programmatically), you just need this:
The
*:D
at the end filters out every message below Debug log level but you can leave that out.To direct the output to, say, a TextView, see for example here.
Update May 17
It's been a few years, and thing have changed. And Eclipse is no longer officially supported. So here's two more up-to-date approaches:
1. Android Studio
In the
Android monitor
toolbox, you can filter logcat perdebuggable process
. Normally, when you develop an application it is a debuggable process. Every once in a while I am having issues with this, and a do the following:Tools
->Android
->Enable ADB Integration
.If it was already enabled, then toggle it off, and then back on
Unplug and replug your mobile device.
There are also options to filter via regex and the debug level
2. logcat-color
This is a nice python wrapper on top of
adb logcat
if you want to use a terminal based solution. The good thing about it is that you can save multiple configurations and simply reuse them. Filtering bytags
is quite reliable. You can also filter bypackage
to see logs of one or more apps only, but you startlogcat-color
right before launching your app.Old Answer:
It seems that I can't comment to previous answers, so I will post a new one. This is a comment to Tom Mulcahy's answer, that shows how the command should change so as to work on most devices, since
adb shell ps
PID column is variable.NOTE: The command below works for the cases where you have connected many devices. So
device id
is needed. Otherwise, you can simply omit the brackets '[', ']'1. To find out the column of pid, type:
Now memorise the column number for the PID. Numbering starts from
1
.2. Then type the following:
Simply put the column you memorised in
PUT_COLUMN_HERE
, e.g.$5
Caveat
Each time you re-run your application, you have to re-run the 2nd command, because the application gets a new PID from the OS.
Package names are guaranteed to be unique so you can use the
Log
function with the tag as your package name and then filter by package name:NOTE: As of Build Tools 21.0.3 this will no longer work as TAGS are restricted to 23 characters or less.
Log.<log level>("<your package name>", "message");
adb -d logcat <your package name>:<log level> *:S
-d
denotes an actual device and-e
denotes an emulator. If there's more than 1 emulator running you can use-s emulator-<emulator number>
(eg,-s emulator-5558
)Example:
adb -d logcat com.example.example:I *:S
Or if you are using
System.out.print
to send messages to the log you can useadb -d logcat System.out:I *:S
to show only calls to System.out.You can find all the log levels and more info here: https://developer.android.com/studio/command-line/logcat.html
http://developer.android.com/reference/android/util/Log.html
EDIT: Looks like I jumped the gun a little and just realized you were asking about logcat in Eclipse. What I posted above is for using logcat through adb from the command line. I'm not sure if the same filters transfer over into Eclipse.
Ubuntu : adb logcat -b all -v color --pid=`adb shell pidof -s com.packagename` With color and continous log of app
Just use the filters inside the logcat. There is a button there that lets you add filters. Just specify the application ID, make sure it is selected afterwards, and you're done, easy!
In addition to Tom Mulcahy's answer, if you want to filter by PID on Windows' console, you can create a little batch file like that: