Improve Your Exceptions Logging with Tinylog 2.1

tinylog is a lightweight logging framework that offers several interesting features for logging exceptions and normal text messages. Besides the Java logging API, there are also special logging APIs for Kotlin and Scala. However, we will use the default Java logging API in this article, since Java is the most commonly used programming language.

Boilerplate-free Logging API

When logging on Java, you typically create a logger instance at class level for issuing any log entries. For example, logging an exception with SLF4J:

Clearer Exceptions with Reduced Stack Trace

Depending on the technology stack, stack traces can become very long, especially when using web frameworks and/or Hibernate. Since version 2.1, tinylog can filter exceptions and stack traces to make the output clearer and show only relevant stack trace elements.

Additional Throwable Filters

Besides the strip throwable filter, tinylog contains three additional throwable filters. The unpack throwable filter allows, for example, to unpack a cause throwable from a wrapper exception. This is useful, for example, if the real checked exception has been wrapped by a RuntimeException, because a called method doesn't allow to throw the checked exception. By using the unpack throwable filter, tinylog can undo the wrapping and output only the checked exception.

How to Continue

Further information and a complete documentation of tinylog can be found on the project website. The logging framework is open source under the Apache License 2. So, tinylog can be used in both private and commercial projects. The tinylog logging API can even be used on Spring and Java EE application severs by using one of the official adapters.

Main developer of tinylog (https://tinylog.org) and Kaseto (https://kaseto.com)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store