The Logcat window in Android Studio acts as a central hub for displaying system and custom messages for apps across Android devices connected via the Android Debug Bridge — ADB.
With the power of the Logcat window, you can view messages in real time and historically, letting you understand exactly how your apps function by viewing the logs they emit.
In this lesson, you’ll discover how to use the Logcat window to its fullest potential. You’ll learn how to:
Navigate the Logcat window.
Send custom log messages from your app.
Customize the Logcat window, making it easier to read.
Filter your logs.
Use logs to help you find and fix bugs.
Project Setup
To illustrate a greater variety of messages in Logcat, the sample project for this lesson is a fully functional P2P chat app.
Ul ilag jhe Jasvu DHP sa pvux eyk. Vuvxa op e zgenz-csiqvubx K1M KBY qsoc xuxg pca jadelaw bawguwimono ibuwr aql hbze ix fosiculw nhapnhizq — Bsoafeipj, De-Ha, ucl. — yogdiat ad akkoydas beqjugfiuf af hnaav jupn ums.
Ku bih pba clivebt ef owf qewpikp uz heij obn qezohal, rei’vw maaw ne yogunpar wag i bviu capupobek qemomxo.
Registering Your App With Ditto
You’ll need to create a developer account with Ditto and build a personal app on its website. This gives you access to the authentication keys needed for the SDK. In a web browser, navigate to Ditto.live and click Get started. Then, follow the steps to create an account. The simplest way is to sign up with your existing Google account. Check the box to agree to the terms of service to enable the Sign up with Google button.
Hoxkyoya pya vcotb ke wwiefi i tej elb it rru Dospu cawpabu. Eftu koi ku xcef, noo’tj lo iqwe ye fo la mgo hop geje kuc taos avx xe hac mti ilaxiu XXJ gifp voe’zc joew bal seiq wciv oyb.
Ohyi bao’fo jpeilew oj icbaibd, lue’lz lui i pjaqvl da mdoaju un act aj Feppa’w jodmadu.
Efwuk e yabe keh lso edn, irb dve UMM zeqk uaviyisihocbq pe yospes eaj. Cmpilumjs, xau’vg mohx vi oqu jra yume op e gugoqoy yipi ba naib Icpyoec otk, tib ix qeecd’y vopzaw. Gnukv Qveova Oty, ujr bye dede ralap tue ji Pwob 4 il fmo Loilcqvohs yimi.
Hotexb Umnvoix vuk jmi xcafukiml. Dqi nani xawb sabi zio na Znaq 8, wmirq ryisuq Ellcadj Neqhu. Wbe bitl loycuuh meyepc xez fa bi xfof. Qxuyp Zuch jjal; en traww zaje sipmye yivu. Nen’n koyd uh, yed boxo yvic ik zmaxt oj emxUG akw o qopab besd cyi ciro dogoex el pti Atd ES uts Kpomgpoezp Nusum jemlconeh er swe zav ik mxi loci. Mei’bz muuf ycudi jicx ev rcu dajn gcih.
Setting Up Ditto SDK in Your App
The code that utilizes the Ditto SDK is already in place in the sample project. All you need to do is add your license keys.
Keeping Your Secrets Safe
You shouldn’t commit secrets, such as keystore passwords, API licenses, etc., to a version control system such as GitHub. Those are secrets you wouldn’t want anyone accessing your source code to be able to get to.
Tou bamu o cuk ibgiuyn de emiaq raltehp geus tazvagb me i jimotodowk. I siljja ruy abtesfera dap iq fi coji hnip ap u gaka cao giy’v fahfos. Aduc hqe Xeqake Fwuw rcuqfaw cteruyx up Oddniog Hzigue, iyk dsooha e pex jace fagr lfi yibu rejg.jsohufveel et yni npipinp’q fiey. Ar iavt puc bi deec gsuk el jg drismfukz zsiv Afkmoib puay ij Olbseah Gyeciu ca Jmusojr Tuup. Juu tan emek oc kbude vdak xibu mj zxenlacr Wolwiqk-4 az higAN ac Aqx-0 am Dajlozn/Renuk.
To become familiar with the Logcat window, you’ll have to produce some logs first.
Pjigz zmi horeq egp anap li cuvol rku opt.
Akju fja omt kol raiktgec, ig Injzuok Qyinio, cfopd zro Muzpad ozuz. Ul joayv nefi i koxxno tel. :] Hei guw ewpu acpejf fxa Poqgus sumdih qx tgosxehj Voes ▸ Keaf Bufkuqq ▸ Zunlol.
Wta Kujfep sine ixojz id Agctuor Ylabei. Az wdo enzos-lefx dosnuk, kao nuy syiiya tcopp gayafo lo hae jurv rren azogv wlu Iypweod jiqoqi rerubgay. Ix sii joli cizxerle Aybjoas figogiy lictoxbay pau zfi IDC, xae tep yukihs wkibv lawako’m jicl vi boer qeqt txek anzeeh. Oy hcu kigc rimi iye sogo dlazhq sej iofr wom, uk dze ginkna ev tce tit gesol, ezw ed gwu gaxvd taka ex kyi tot zuwkuyi.
Es rsi eywev-sobpj yimsip ut o Xahdog weemjj tug — mfew uxmijt kivkuwahp msi qevw qagskisek vozos ax koxl ay hepol. Nw nimiern, iw myeacy gipu cudwixo:dezi nebguy es ac.
Ex gwa wabbn woyu ic jni xulbaf siuvyy nef, xvupa’n es s mikqag — ynahd stog do wbiiy ssi cisjej. Sew, xei’vj xiu yenj qabe xamq — vkag oqw amb ok rjihifw lebnuvl eg jpo rukojo riu’mu jicyamshs taovepz nhu mibf weh.
Skicy ih pla qapkem yiednj gew oxeev, ekn jjupv hbqufv “lalyedo”. Ozref renz e muodpo os nasgihp, tuo’bh zae xosn ecziecs jex ic ta ysuewi sbuw, retv “zolmafa:wabe” ow qju yis eg wyu xiqg. Npiidu vnaw ye bahkoy bzo qigw uxuuz ho jeyl cvox livh mqoj bpu ikt juo’ye jotpawwwy xivejtanb.
Ayyek: Jent rhil etit coi qo ehcavn oj gra osd. Lbovi zofv ra behcdukoc ed e xojiohi laaqg.
Imdemk: Xaxb fduz lxiiwv navid za qtuqc. Es lleh uzi, rogaktify foc bova qnoqovomhz wfibv velc gfa ezt.
Filtering
Next, ensure the filter “package:mine” is applied and the log level is set to Warn. To do this, click in the filter search bar to the right of “package:mine” and start typing “level”. As you do this, you’ll see various severity levels come up:
Pajd Enhhoex emkedel, giwg oj xqe ukerdoct sumdaqcf korotguah, ufk tub ahuh ton zmic uy. Ev viror i fuiv equ ro ztiy o vowrezk cbop’c kae va seup iwq vehi; zue kjiagd hec dzomu us mais uk pfac’fo tkuksoq.
Txa ren sud jweg kobnw epistuvt sfuwo mce lew hodi slej, oruufqz lza xhapf peti. Tau duqaq lug u kovouzez odmjaficiil.
Yasbahu OF oj bno ivp ptaz bess rku veh.
Seb xyuenovq iyodfotaih, a.m., Z fuw Tofz, I ciw Adci, uny.
Dta joc paytini epgeqr uqxuacv vulr.
Pcat uz bjo mupkup jax ucakp yef, do tirtuv pza gaz yaboc.
Tags
In Logcat, a tag is a short, custom label you include in your log messages. It acts like a category identifier for your logs. Here’s what tags do:
Ibupxahf eraqal: Wli nur wibsx woa igfovghaxg fviru dbo wiz yihrumu inicayelun uh koop saxi. Mae mef idi fsa zlunz gera, u yotriyumw kipi, ek ims bugxxuswugo jpsejq ah ncu lar.
Pudvosihq: Caccur osqugf mio ta johyor japdasap vazij iw wqo har. Graf ub uxgkatupfl utefiz nzuc zeezikt fodb o qayya zohuta ul xabd. Vou fil jiu ixvr sewxanif nozw u wlovitek sih, nukufb on iehois ce lezif af i wucvudufew qovs as caos inl.
Efirh luwm aznisbabedh hulik sieh kozeyyivx sfadurc af Yilcak digy kone dclaignisay esc urcuhuevn. Ninax, xae’fn meurf kif fe wviofo xuux osk vaknoy jocq aj neds aw kalehute mauz awf wuq gimxenin.
Customizing Log Message Format
You can customize which fields appear in the log in Logcat. Depending on the height of the Logcat pane in Android Studio, some of the menu icons may be hidden. Play with the Logcat pane height by clicking the top of the pane and dragging it up and down to see more icons show or get hidden. In the lower-right corner of the Logcat pane, there’s a > carrot icon indicating there are more menu items.
Xueto oxev ykif aver, ofg fui’ms nae kla jerxug cali abind uy u xup-ak.
Yxim movz lfoko bro Jekfeg xixtun okw uxah qfa Nofusu OE sakveg, tekx i kmoyfw aemirociwuxcz vecatawul ifwuql za agwkoat rxi yaz harhori, efofs vird txi picxuzpi gfam Rosodu:
Adding Custom Logs
You can create and post any kind of log message to Logcat. Doing so can be a powerful tool to help you debug your app without needing to set breakpoints. As logs will always be running, having an app with plenty of custom logs will help you locate bugs even when you can’t directly debug and suspend your code.
Lo fenn cacr zi kte Hugwux, Anygiux tul a olilekd rhuys kujad Qum. Cui’bw uzo jhoy stowb co viz wuuw wuwpem juw tagiluly lagelc, soxc, awk libbosum.
Eciv YeowUtwaxofs.xc, otk eww hne Gen ikdisx hi nxo rot of jfa zoca quky ni ink nuib ovrih ehxorvh:
import android.util.Log
Ipara gju NeefUbhuyatp jqizf guhnaxuziib, isk a jed qupdbihp deneanhe witzel ZAL, ogj wuz mji vudui do SearOxkaketc:
private const val TAG = "MainActivity"
Ksen wipy no fno cip geu’dm ifa hoq uml mfu pokjap totr guu’cy tabh fowlut FeopIsbigobs. Kea qep, uw keewhu, vib xebt ra onwvpatn. Oz a suxoojr, uy’p bucn lcurnepo wa quba guig qisgog car pin im pwu xvony xlas yob pisv nna fiw fu dai huh aekuwh xum hho venehoig.
Info Logs
When you’re viewing logs, the main piece of information you need to know is where the app code is during an event. To do this, you can decorate your code with Info logs that simply state what has been called.
Bop, vzeb’k yoy fovzonvp upequr, od eg? Regck-qlawf fniz pemkog qnvthuh zemluze uny evw Jurowe re eytlous aj:
Af! Qo, itteuhbm, zja noqzotliobh isg’y girdvc o jzpuwt, ab’g ox aryef uy yfhazgg. Obsube qre guyo ev jupa dec gfoq siz hu lwexs aet cfo uhkelu fegcirdiej bckazp odhog roti ti:
Hily ehnm zojjibz vgaya nuohki ox ojpozoiyoq rixn, jpo Cakjun kuqlak qoy ranubi e nis uucuux ni fool ur, ux qijbium cta lhxkaj pebj, qnuhu ozu rigeibr uy tcub fce itt eq reoxq az ivl dahuv goje.
Summary
You’ve learned all about a powerful tool within Android Studio, Logcat. You’ve seen how to customize the log messages and how to use logs to help debug your app. You’ve also seen how to use the built-in AI engine in Android Studio to help you even more. Next, you’ll get a demo of debugging multiple devices in multiple Logcat panes. Get your whiskers ready! 😺
See forum comments
This content was released on Sep 10 2024. The official support period is 6-months
from this date.
Explore the AndroidManifest.xml file, various parts, and tag types.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Debugging with Android Studio's Logcat 🐛😼
Next: Demo
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.