Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7642813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:17:05+00:00 2026-05-31T09:17:05+00:00

In an android app I am trying to get my application log messages and

  • 0

In an android app I am trying to get my application log messages and saving them to file
I am using the code below.
I am using a different TAG for each of my class and there are several of them.
doing logcat -d gives me all irrelevant messages..
putting my package name like

logcat -d myapp.com:I *:S

does not work the results are empty but if I do

logcat -d MYCLASS1TAG:I MYCLASS2TAG *:S

then it works, but I have many classes..

how can I just put my package name and get results ..??

try  {      
       Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

   String line;  

   while ((line = bufferedReader.readLine()) != null) 
    {


 //       write to my file here

   }
  }  catch (IOException e)    {   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:17:06+00:00Added an answer on May 31, 2026 at 9:17 am

    I’m not sure how to do it from the command line, but the ADT plugin for Eclipse lets you filter by application.

    edit: I was curious, so I looked through the ADT source to figure out how ADT does it. The long and short of it is that it uses the -v long option to include the PID with each message, and it keeps a Map from a PID to an app name. The relevant source code files are in the package com.android.ddmuilib.logcat.LogCatMessageParser and com.android.ddmuilib.logcat.LogCatPidToNameMapper.

    So, one workaround I can think of is to call up a shell (adb shell), figure out your PID using ps, and then pipe the output of adb logcat to grep:

    adb logcat -v long | grep <your PID>
    

    It will be a bit of a pain since your PID will change every time you run the app, but that’s how you can do it in a pinch.

    edit: I just noticed that the long format actually prints the PID on one line and the message on the next line, so you may need to use something like awk instead of grep. I’ll test a few things out and post a followup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(post updated for working code) I've been trying to get my android app to
I'm trying to debug an android app that call native code to do some
I'm new to Android development. I'm trying to get a simple HelloWorld app going
I am trying to run an Android application on a BlackBerry PlayBook Simulator using
I am trying to build a web app for Android device using Senahc Touch
Trying to get an Android 2.2 application to start up with a SurfaceView as
Hi I'm trying to get files in my res/raw folder of my android application
I am trying to writing code so that my android application can query a
I am trying to get the installed application in Android after clicking a icon.
I'm trying to use a custom class (be.myname.rssreader.util.Global) extending android.app.Application, but when I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.