Is there a way to view log messages from our own android application?

I developed an Android app that does some network activity. Inside the classes, I implemented log messages such as verbose, debug, info, warning and error. But when I open logcat with the -d argument, it lists all the log messages from the device. Therefore, it is difficult to track the log messages of my application. Is there a way to filter my application's log messages from all logcat output?

+2
android logcat
Aug 13 2018-11-11T00:
source share
2 answers

Each Android Journal post has a tag and its associated priority:

The tag of a log message is a short string indicating the system component from which the message originates (for example, "View" for the view system). 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) 

Here's how to do it:

  adb logcat ActivityManager:I MyApp:D *:S 

This will result in logs with an ActivityManager tag if they have a priority of Info level or higher (Warning, Error, Fatal). The same goes for messages with a MyApp tag and debug priority or higher. *: S makes all other messages silent.

Check this out in the documentation: http://developer.android.com/guide/developing/tools/adb.html#logcat

Additional tips

  • I suggest that you keep all other logs at the error or warning level ( *:W ). Sometimes you have a problem in the application due to a system event or a third-party application, and you want to receive notifications about these events!

  • You might want to change the logcat output format. Play with these settings (information in the same link above)

  • You might want to check the color output for logcat. I made some changes to this script to better suit my needs, so maybe you can adjust it too. (I tried to send my changes to the author, but he did not respond).

+5
Aug 13 2018-11-11T00:
source share

Logcat has a small + button that allows you to create a filter. Use the TAG that you used in your application and specify it in the filter. This creates a new tab that displays only your application messages. While you're on it, I recommend creating a filter for the AndroidRuntime tag. All your exceptions get there, and you can find them very easily.

enter image description here

Of course, you can filter these messages by category (verbose, warn, error, ..) using the buttons on the same line.

+3
Aug 13 '11 at 13:10
source share



All Articles