Results 1 to 7 of 7
Like Tree7Likes
  • 6 Post By JHutson456
  1. Thread Author  Thread Author    #1  

    Default Learn to logcat like a Pro!

    adb logcat bootcamp

    I'm going to be teaching the basics of logcats. I sat for a few hours a while back and hammered all this stuff out with ckisgen from XDA/ACS holding my hand the whole way, so this is good info here. I did the whole thing in Ubuntu (Linux) and have listed the Window$ $pecific desktop pathing below the Linux command. UNIVERSAL COMMANDS LINUX COMMANDS WINDOWS COMMANDS.

    When I say Terminal, I mean Command Prompt for you Window$ u$er$ (start-run-cmd)

    In terminal with your phone plugged into the computer


    A Logcat:

    Code:
    adb logcat
    This doesn't START logcat, this tells terminal to grab the information already on the device logcat and display it in terminal. This isn't so useful to us. It just scrolls the information in terminal and you can read it there. This is kinda difficult to read though, for one it's constantly scrolling as your phone does things and two, it's likely that your terminal is configured to only allow a certain number of lines to be kept readable before they drop off.


    Pipe it to Desktop as a .txt file


    Code:
    adb logcat > ~/Desktop/logcat.txt 
    adb logcat > %userprofile%\desktop\logcat.txt

    This command above will tell the logcat to export the terminal logcat to a .txt file on your desktop called logcat.txt The '>' symbol tells the logcat to pipe to the location listed. This will continue to update even if you open the text file, so long as you have terminal running. It's not done “live” though, you have to either refresh the file, or close it then re-open it. That won't affect anything other than giving you an update. Now we're getting somewhere, but where?


    Code:
    adb logcat > /sdcard/logcat.txt

    If using Terminal Emulator on your phone instead of a computer setup, this (above) is the code you'd want to use. It will save the logcat.txt to the root of your SD card. Next!


    -v long, or not to -v long, that is the question!


    Code:
    adb logcat -v long > ~/Desktop/logcat.txt
    adb logcat -v long > %userprofile%\desktop\logcat.txt

    Now we're telling the logcat to do something more interesting. We are telling it to give us every scrap of information it has. This will space the logcat out nice and pretty and really make things easier to read as well, even giving time stamps of when everything happened! Now you can say “it happened at about 9:30 pm” and we can find that. Winning!
    Sometimes you want to filter down the information though. You want to make the dev's life easier. Here is how:

    First, a brief on Tags and Priorities.

    Tags are going to be what process is actually giving the information, for example 'ActivityManager', 'Database', and 'WindowsManager' are all Tags you can find. There are TONS of these suckers! Research into what your problem is and try to pick out the tag.

    Priorities are different. These will tell you how serious the issue at hand is. The priorities are called by their letter code and are:

    V Verbose
    D Debug
    I Info
    W Warning
    E Error
    F Fatal

    S Silent (suppress all output)

    These are in ascending order. In other words, Verbose or V is going to be the micro information which doesn't really mean much to anyone 99.99% of the time where as Fatal or F is going to be a huge catastrophic issue. When filtering for a Priority it will include the Priority you give PLUS all HIGHER Priorities. So, for example, if you call to filter for Warning or W then it will give you Warning, Error, and Fatal. That is common to filter for. Below are some examples of code:

    ( PS - you would never actually type or input ‘{‘ or ‘}’ in your logcat commands .. they are in some of the examples below to show you that these are generic modifiers … meaning - if you were actually inputting the command you would replace the {Tag} with an actual Tag, like: ActivityManager or GTalkService .. in the same way you would replace {Priority} with an actual Priority, such as: W or E )


    Examples


    Code:
    adb logcat {Tag}:{Priority} *:S > ~/Desktop/logcat.txt
    adb logcat {Tag}:{Priority} *:S > %userprofile%\desktop\logcat.txt

    The above line is if you know exactly what Tag (GTalkService or ActivityManager) and Priority (W or E) you are looking for.


    Code:
    adb logcat *:{Priority} *:S > ~/Desktop/logcat.txt
    adb logcat *:{Priority} *:S > %userprofile%\desktop\logcat.txt

    The above line is if you don't know the Tag, but know the Priority. The * is a wild card that basically means all/any. An example of a VERY valuable logcat could be:


    Code:
    adb logcat *:W *:S > ~/Desktop/logcatALLwarnings.txt
    adb logcat *:W *:S > %userprofile%\desktop\logcat.txt

    So, the command above would give you all tags that had a priority of Warning, Error, or Fatal. It would silence (not show) everything else and would pipe the output of your log to your desktop as a text file named logcatALLwarnings.txt … moving along …


    Code:
    adb logcat {Tag}:V *:S > ~/Desktop/logcat.txt
    adb logcat {Tag}:V *:S > %userprofile%\desktop\logcat.txt

    The above line is if you know the Tag but want to see all Priorities. {Tag}:V outputs all priorities for the specific Tag you’ve entered because it calls for the V (Verbose) priority, which is the very lowest priority … and as you recall, it always gives you the priority you’ve asked for AND above.

    The *:S tells the logcat to Silence (or ignore) all lines/messages that have not otherwise been specifically called for using these filter expressions. This CAN cause issues though, sometimes it will silence what you're looking for / everything.

    A final specific example from my phone to be clear. I got a Database Tag with an Info Priority, if I wanted to see all instances of this happening, I could use the following code:


    Code:
    adb logcat Database:I *:S > ~/Desktop/logcat.txt
    adb logcat Database:I *:S > %userprofile%\desktop\logcat.txt

    Or, if I had an ActivityManager Warning I could use


    Code:
    adb logcat ActivityManager:W *:S > ~/Desktop/logcat.txt
    adb logcat ActivityManager:W *:S > %userprofile%\desktop\logcat.txt

    Ok, now we're going to the show! You know the tools, but how do I use them? Glad you asked!

    For the first time you boot a ROM/Kernel bundled together (IE InsomMIUI 1.12.2) or for just a kernel you're going to do the following:

    Once you're finished full wiping and installing the ROM, but haven't rebooted the phone yet. (Or wiping just the caches for a separate Kernel):


    • Open Terminal on your computer
    • enter the following code


    Code:
    adb logcat -v long > ~/Desktop/logcat.txt
    adb logcat -v long > %userprofile%\desktop\logcat.txt




    • Name the logcat something useful. A good format is to use you're initials, rom name, what it is, and date. This way it stands out. So the code with the really long but helpful file name would be:


    Code:
    adb logcat -v long > ~/Desktop/JH_InsomMIUI1122_firstboot_5Dect11.txt
    adb logcat -v long > %userprofile%\desktop\JH_InsomMIUI1122_firstboot_5Dect11.txt


    • Yes, I know that's a long name, but we look at dozens of these things, it helps!
      • In recovery tell it to reboot the phone. The logcat will start recording internally on your device at boot automatically.
      • Once the phone is at the lockscreen let it sit for 5 minutes.
      • Unlock the phone and let it sit for about 10 seconds.
      • Restart the phone.
      • Once you restart the phone open the logcat file on your desktop to make sure it’s not blank/empty/something went wrong and if everything’s golden - send to your favorite developer (ME! ).







    • FYI , the -v option sets the output format. -v long after the logcat command formats the log so that it adds a date and time stamp to each line. It also separates each line with a blank line .. making the log as a whole much easier to look through.





    • That's it, you should be off to the races with these logcats. I hope this has helped!
    AndroidInsomnia RESPAWN LOL
    Thanked by 16:
    + Show/Hide list of the thanked
  2. #2  
    chrstdvd's Avatar

    Posts
    88 Posts
    Global Posts
    251 Global Posts

    Default Re: Learn to logcat like a Pro!

    I read this thread and started thinking that I had seen one of these text files somewhere on my computer. I think it is this one because you can click the arrow where it now says Verbose and have the other choices you have instructed about in the post. I will have to study your instructions and see if I can do a script to mimic what this screen shot is showing. Thanks

    Learn to logcat like a Pro!-logcat-725x485-.jpg

    See where it says "fail port mapping". That means I can not connect my phone over 3G/4G to this computer. I have the same problem with the Plex application, but they must use really verbose logs because I can not read them well. Now that I know this, I will tinker with the Plex application and see if I can make a script to make a log a little more understandable.

    I know the reason now why port mapping fails; it is because I use Hughes Net as my ISP and they block all ports unless you purchase a static IP address for your system. I got around the problem by using Audio Galaxy which works similar to a cloud server but does not upload my media to the cloud, like say Google Music would.
    Last edited by chrstdvd; 12-15-2011 at 06:54 AM.
  3. #3  
    srkmagnus's Avatar

    Posts
    6,751 Posts
    Global Posts
    6,754 Global Posts
    ROM
    Stock 4.4 (KitKat)

    Default Re: Learn to logcat like a Pro!

    Is there any personal data from the logcat created? I've always Wondered anything could be sent that I don't want floating around in a logcat.
  4. Thread Author  Thread Author    #4  

    Default

    Quote Originally Posted by srkmagnus View Post
    Is there any personal data from the logcat created? I've always Wondered anything could be sent that I don't want floating around in a logcat.
    I can tell a lot but I don't recall ever seeing anything like a text message print or the like. Let me play around and see.

    this has been a message from the dead pool.
    AndroidInsomnia RESPAWN LOL
  5. #5  
    srkmagnus's Avatar

    Posts
    6,751 Posts
    Global Posts
    6,754 Global Posts
    ROM
    Stock 4.4 (KitKat)

    Default

    Thanks :-). I understood the value a logcat gasvto developers but always wondered about this.

    Sent from my HERO200 using Tapatalk
  6. #6  
    Jsmokey's Avatar

    Posts
    7 Posts
    ROM
    Antares Darkcloud by Me

    Default Re: Learn to logcat like a Pro!

    Great little guide Jhutson. I completely understood reading logcats prior to this but a few of the extra command options I hadn't bothered with before so it was a nice little refresher on a a few points to me and definitely a must for anyone aspiring to do any sort of mods to android especially with all the posts I've came across in the past asking for explanations on how to read logcats which really should be everyones first step to modding aside from learning the file types, what they do and which one's are absolutely necessary for android to run without any fc's, bootloops, etc...
    My captivates setup:
    Rom: Antares Darkcloud based off KH3 (My Rom)
    Kernel: Red Nebula KH3 (Also by me)
  7. #7  

    Default Re: Learn to logcat like a Pro!

    Thanks your commands really helped this noob, but couldn't use them until I downloaded the sdk tool kit form another site will post another comment with a link for a good video to help anyone else who stops by here.

Posting Permissions

B