Android Studio 3.0 Logcat continuously showing messages and does not stop - android

When I start debugging my App in Android Studio 3.0 and open the Logcat, it displays so many messages and warnings, but the problem is, it never stops, even when the debugging is completed and the App is terminated, it still prints so many messages continuously.
Can anybody help???

Since you are not debugging or running any application on the device you have connected. Hence, the logcat is displaying the logs generated by all the apps in the device as well as the system logs. Which makes the log cat window go nuts.
What you can do is.
On the top right corner of the log cat window, there is a filter config combo box. Select or create a filter of your own to filter out relevant logs.
The filter could be created using any details, it could be a process ID (PID), the tag name e.g I/ActivityManager: where I stands for Info, V for Verbose, D for Debug and so on.

You can add filter in your Logcat, and mention all the classes whose logs you want to discard.
In the field LogTag (shown in the pic) define a regex like this ^(?!Class A | Class B|#). Here Class A and Class B are the classes whose logs you don't want to see.That's it.

If you see no debuggable application then change it to your app name. If that wont help change the log level to error. Last thing you can try is to filter the results. Good luck!

Related

Android Studio: Logcat vs Run

What's the difference between Logcat and Run in Android-Studio?
Logcat has filter-options. Beside that I don't get which specific purpose each serve.
In how far do the messages differ, which become printed to each console?
When do I use which console?
Personally,Logcat is more useful for debugging and being aware of what is going on while the app is running. You set the type of the log and set tags to them, by this way you can easily filter logs. This gives you much more clear picture in terms of logging.it stated in this article
Logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that you have written from your app with the Log class.
Also, it is stated that (in the same article)
The priority is one of the following character values, ordered from lowest to highest priority:
V: Verbose (lowest priority)
D: Debug
I: Info
W: Warning
E: Error
F: Fatal
S: Silent (highest priority, on which nothing is ever printed)
each one of these shows the logs from their priority to highest one . Verbose, for instance, will print all the logs but if you switch to error , logcat only shows error and fatal logs.
Additionally, if you set a tag filter it will only shows the logs that is tagged with that "tag", of course while keeping the priority filter. For instance
Log.e("tag1","message_1");
Log.e("tag2","message_2");
Assume you have filter the tags with "tag1". The logcat will print "message_1".
Similarly
Log.e("tag1","message_1");
Log.i("tag1","message_2");
Again, assume that you have filter tags by "tag1" and priorities with Error.Then, the logcat will show only "message_1".
For the run tool also shows logs , prints (println etc.) but in comparison with the logcat it will show a lot more stuff (logs, prints (println etc. and phone related informations).
apart from your logs other logs that comes from libraries and phone itself also are shown in the run tool. So it hard to find your own logs.
Run will be useful when the phone and library related information logs needed.(for instance when the phone misses/drop frames it will be printed in run)
Logcat will be useful for your own logs.When you are trying to understand what is going on while the app runs etc..
I have noticed a big difference between the run and the logcat while using avd emulators. I had a deceiving crash on my app, only while I was using the emulators .
every time there was a crash , the logs before the crash were disappearing from the logcat , and I couldn't understand if I see the logs related to the crash. after a week of trying to find a library that prints the logs to a file I found out that everything is printed in the run tab, so I don't need that.

How to print a string to logcat for testing?

I know this question has been asked before, but I can't find a clear answer. I'm new to Android Studio and the logcat console confuses me. I have a string date and I want to keep 'track' of it in the console so I know what value it has.
I tried commands like Log.i and console.log, but they don't seem to work for me.
Where should I write my print line code?
Where can I see it when it gets printed?
Do I have to run the whole app (on the emulator, or on a device) to print the line to the console?
Where do I write my print line code ?
That is up to you.
Where can I see it when it gets printed ?
In LogCat:
You will get this from the Android view (usually docked on the bottom edge on the left side). Note that I have sometimes encountered a bug where the automatically-applied filter for your app (right-hand drop-down list, above the output) seems to result in nothing showing up in the output. You may need to remove the filters, then adjust the output based on log level.
You can also view LogCat at the command line via adb logcat and in the Android Device Monitor (Tools > Android > Android Device Monitor from the Android Studio main menu).
Do I have to run the hole app (emulator or via a device) to print the line to the console?
Yes.
Your use of Log.i is the correct way to write to Logcat. Here is the documentation for Log.
I typically use a tag that describes the stage I am in (setup, teardown, UI update, etc), and I will usually log any action that can trigger an exception.
To view the Logcat, there should be a window for that in Android Studio. When the windows is not visible, you can access it from a tab in the lower left corner of the screen:
if you want to show logs in error
you can write
Log.e("Your Tag for identy", "Your String ");
if you want to show logs in info
you can write
Log.i("Your Tag for identy", "Your String ");

Using Android Studio's logcat better, permanent focus on a single process?

When testing on a device in Android Studio you get an awful lot of output in the logcat.
I'm only interested in the output for the app I'm developing. I can see just this, after running, by opening the Devices section and manually selecting my apps process. Problem is, it's pretty tedious to do this every time I run my app, which seems to be the case.
Is there a way to get it to remember this setup?
How about a way to get it to stop reporting anything after I'm done with my app or it's crashed ? (otherwise my app specific stuff gets buried so quickly by output from other proccesses on my phone)
I'm open to other ways of filtering the logcat too, however I couldn't think of a way to set up filters so that I would get my tagged Log messages AND other exceptions I wasn't expecting.
Any suggestions?
Normally this is done by default, but if not,
in logcat, the green plus sign, when you click it you get a dialog, fill the byApplicationName with your package name, and also your filter name with something, now you can filter your output according to your app
with that beeing said, sometimes you don't get the filter column info (application name) in logcat at all (blank), here (and I my self don't know the cause of it) just forget it for a while and retry again

Eclipse Logcat goes crazy

I was using my Eclipse Logcat crazy normally until yesterday where it started displaying messages without stop.
My message that I am printing using log.d are no longer printed to the log.
Or maybe they are but because of the huge number of messages printed they are gone.
The messages do not stop printing to the log whether I am using the app or not.
The only way to stop it is to unplug my device from the PC otherwise the messages will keep flushing to the logcat
Any suggestions ?
Thanks in advance :)
It sounds like you have no filtering of the log output and therefor sees output for every app on the phone.
Create a logcat filter with your application package name.
In the logcat window, go to "Saved filters", create a new one (if Eclipse hasnĀ“t autocreated one for you) by clicking plus-sign to add. Type a name of your filter and write your application package name under "by Application Name". Click "ok".
When you select it you only see logcat outputs for your specified app.

Eclipse - Limit logcat output to debug relevent logs

I reinstalled my Eclipse and now my Logcat logs everything my phone sends like battery status or mail sending status.
Is there a way to tell Eclipse/Logcat to just log what is really coming from my app which I'm debugging?
Filter the Logcat with "app:com.yourdomain.appname". I've also added a filter that gets rid of more items using a not operator:
tag:^((?!CoreMetrics|InputEventConsistency|memalloc|Adreno200-EGLSUB|Resources|global|TaggingRequest|Facade[B|U]|dalvik|skia|KeyCharacterMap|BackStackEntry|FragmentManager|ServiceRunnable|ServiceLocator|BaseHttpRequest|szipinf|APACHE).)*$
You'll need to edit the list specifically for the items you're seeing, but it's a great way to reduce the static.
You can log using a Tag and then filter in logcat using the same tag. You can add a filter by clicking on the + in the left hand side list. You can recognize it because the first tag will be "All Messages". Clicking through the list enables the filters.
Log.i("MyTag", "some log message");
Also in newer versions of the ADT eclipse plugin, I blieve that it auto-adds your app to the filter list.
In Your LogCat click button(Second Last) to left of the "downarrow button" the click "plus" sign write filter name and in application write the package name of the app you wanna get filtered logs for examole com.yourapp press ok and viola !!!
You can enter search filters in the search box at the top, or you can make those filters permanent via the filters panel visible on left side of eclipse logcat window. If it is not visible then note the button on the top right of logcat that displays/hides it.
"Is there a way to tell Eclipse/Logcat to just log what is really coming from my app which I'm debugging?"
Not exactly. You should be able to do that with the filter "app:com.yourapp". This filters based on the 'application' column/data of the logcat output, which would be perfect but Android devices are rather eratic at adding that information to debug output. Actually, the Nexus 4 is the first phone I've used that reliably specifies that data field in its logcat output.
But even if 'application' column doesn't work for you, you should be able to find other filters that reduce the visible log statements to a manageable level.

Categories

Resources