# Kermit and Crashlytics

DevFeed: [Kermit and Crashlytics](<https://devfeed.tech/articles/kermit-and-crashlytics-25948.md>)

Original publisher: [Read original article](<https://medium.com/@kpgalligan/kermit-and-crashlytics-27d7bc953576?source=rss-c2f810aa7890------2>)

Author: Kevin Galligan

Published: 2022-01-05T19:59:46Z

Content type: article

Language: en

Sources: [Stories by Kevin Galligan on Medium](<https://devfeed.tech/sources/stories-by-kevin-galligan-on-medium.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [Crashlytics](<https://devfeed.tech/topics/crashlytics.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Monitoring](<https://devfeed.tech/topics/monitoring.md>), [Logging](<https://devfeed.tech/topics/logging.md>)

Tags: [crash-reporting](<https://devfeed.tech/tags/crash-reporting.md>), [crashlytics](<https://devfeed.tech/tags/crashlytics.md>), [exception](<https://devfeed.tech/tags/exception.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [logging](<https://devfeed.tech/tags/logging.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [monitoring](<https://devfeed.tech/tags/monitoring.md>)

## AI overview

This article explains how Kermit, a Kotlin Multiplatform logging library, integrates with Crashlytics for crash reporting. It focuses on iOS, where Kotlin exceptions can produce reports that omit the Kotlin stack and exception message, and describes registering an uncaught exception handler to send that information in a separate non-fatal report. The approach results in two reports for each crash event.

## Source excerpt

Cross post from https://touchlab.co/kermit-and-crashlytics/ Kermit is a Kotlin Multiplatform logging library. The log is configured on each platform to write to various, potentially platform-specific, outputs, but can be called from shared "common" Kotlin code. Crash reporting tools like Crashlytics allow you to get error reports from remote devices running your software. These tools are very common in mobile app development, and in most cases are critical for monitoring application health in production. Crash reporting for KMP involves a setup similar to other platform-specific libraries that you want to use in a KMP context. You configure each platform according to the documentation from the software vendor, then have some common Kotlin code that can interact with the platform-specific library. Crash reporting is a bit of a special case for iOS. It's a long story, but the summary is the JVM and Kotlin throw unchecked exceptions up the stack, and if unhandled, eventually wind up in a catch-all handler. On iOS, exceptions don't work the same way. When a crash happens the runtime essentially stops and a handler is called. The crash library gathers the state of each thread's stack and sends that to the server. If you call a Kotlin function on iOS and an exception is thrown from somewhere in that Kotlin call stack, the Kotlin runtime will bubble the exception up the stack like it would on the JVM. At the "border", where you first called the Kotlin code, the Kotlin runtime will trigger a crash. If you look at the crash reports you'll see konan::abort() . That's the Kotlin runtime (internally called "konan") force-killing the process. That "works", and if you don't need symbolicated Kotlin crash info, then you're done! However, all of the crash reports will lose potentially vital info. Specifically the Kotlin stack and the exception message. To get that info, we register an uncaught exception handler with the Kotlin runtime, and when a crash originates in Kotlin code, a