From cb37a0909420235cd8f15b5ba12652edece3c056 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Wed, 27 Aug 2025 10:53:37 +0200 Subject: [PATCH 1/2] Directly document how to use Logs for certain Android integrations instead of linking --- .../android/integrations/timber/index.mdx | 2 +- .../logs/integrations/android.mdx | 89 ++++++++++++++++++- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/docs/platforms/android/integrations/timber/index.mdx b/docs/platforms/android/integrations/timber/index.mdx index 6db43b482946ca..a1e5e41136c6ff 100644 --- a/docs/platforms/android/integrations/timber/index.mdx +++ b/docs/platforms/android/integrations/timber/index.mdx @@ -32,7 +32,7 @@ plugins { Then, initialize the [Android SDK](/platforms/android/#configure). -The Android SDK automatically adds the `SentryTimberIntegration` if the `sentry-android-timber` dependency was found on the classpath. The integration is added with `minEventLevel` set to `ERROR` and `minBreadcrumbLevel` set to `INFO`. +The Android SDK automatically adds the `SentryTimberIntegration` if the `sentry-android-timber` dependency was found on the classpath. The integration is added with `minEventLevel` set to `ERROR`, `minBreadcrumbLevel` and `minLogsLevel` set to `INFO`. However, you can still override the default behaviour by adding your own instance of the `SentryTimberIntegration`. For that, refer to the [manual installation](/platforms/android/integrations/timber/#configure) section below. diff --git a/platform-includes/logs/integrations/android.mdx b/platform-includes/logs/integrations/android.mdx index 2f388c01e64a74..946b5394e51fec 100644 --- a/platform-includes/logs/integrations/android.mdx +++ b/platform-includes/logs/integrations/android.mdx @@ -1,5 +1,86 @@ -Available integrations: -- [Timber](/platforms/android/integrations/timber/) -- [Logcat](/platforms/android/integrations/logcat/) +### Timber -If there's an integration you would like to see, open a [new issue on GitHub](https://github.com/getsentry/sentry-java/issues/new/choose). +The Android SDK automatically adds the `SentryTimberIntegration` if the `sentry-android-timber` dependency was found on the classpath. The integration is added with `minLogsLevel` set to `INFO`. + +If you want to customize these levels, please have a look at [Timber docs](/platforms/android/integrations/timber/#configure). + +If you are not using our Gradle plugin, please have a look at [Timber docs](/platforms/android/integrations/timber/#install). + +This snippet captures an intentional error, so you can test that logs are working as soon as you set it up: + +```kotlin +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import java.lang.Exception +import timber.log.Timber + +class MyActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + try { + throw Exception("This is a test.") + } catch (e: Exception) { + Timber.e(e); + } + } +} +``` + +```java +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +import java.lang.Exception; +import timber.log.Timber; + +public class MyActivity extends AppCompatActivity { + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + try { + throw new Exception("This is a test."); + } catch (Exception e) { + Timber.e(e); + } + } +} +``` + +### Logcat + +The Sentry Android Gradle Plugin automatically captures Logcat logs of level `WARNING` or higher. + +If you would like to change the minimum level, please have a look at [Logcat docs](/platforms/android/integrations/logcat/#configure). + +This snippet captures an intentional error, so you can test that everything is working once you've set it up: + +```kotlin +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import io.sentry.Sentry +import android.util.Log + +class MyActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + Log.w("MyTag", "Warning message.") + + Sentry.captureException(Exception("My Exception")) + } +} +``` + +```java +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +import java.lang.Exception; +import io.sentry.Sentry; +import android.util.Log; + +public class MyActivity extends AppCompatActivity { + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.w("MyTag", "Warning message."); + + Sentry.captureException(new Exception("My Exception")); + } +} +``` \ No newline at end of file From 7c47f1c6a559d17bce38dd434b11aefeec355f07 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Wed, 27 Aug 2025 13:19:53 +0200 Subject: [PATCH 2/2] Update platform-includes/logs/integrations/android.mdx Co-authored-by: Stefano --- platform-includes/logs/integrations/android.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/logs/integrations/android.mdx b/platform-includes/logs/integrations/android.mdx index 946b5394e51fec..b991a57988237e 100644 --- a/platform-includes/logs/integrations/android.mdx +++ b/platform-includes/logs/integrations/android.mdx @@ -20,7 +20,7 @@ class MyActivity : AppCompatActivity() { try { throw Exception("This is a test.") } catch (e: Exception) { - Timber.e(e); + Timber.e(e) } } }