Using Timber with Crash Reporting Tools

Semih Bozdemir
2 min readJul 3, 2016

--

I was using Crashlytics to report crashes in my Android apps. Last Google I/O, Firebase was launched with expanding its services. One of them is Firebase Crash Report tool. I wanted to give a try to it, but I could not stop using Crashlytics as well. It was working properly. I also wanted to compare them. Finally, I implemented them together but there was a problem. It was too much code to log an exception. Then, I found Timber which is a logger utility library to solve this problem.

That is the code which shows the problem below. There are three lines in the catch block to log exception. If I decide to use more crash reporting tool, much codes will come here.

I can create a class, add a static method and move those lines there. However, using Timber is better, trust me. It has a extensible API instead of one method.

So, that is the try-catch block with using Timber.

Add these lines to your Application class or somewhere logical so that Timber does its job.

Timber uses Tree instances. You have to plant(initialize) it with your Tree instance before using it. I initialized it according to build variant. If it is debug, exceptions will not be reported.

On a final note, I guess you realized something confusing. There is no LOG_TAG anywhere. Timber also handles this and pass the class name as a log tag for you. That’s cool, huh?

--

--