|
1 | | -Available integrations: |
2 | | -- [Timber](/platforms/android/integrations/timber/) |
3 | | -- [Logcat](/platforms/android/integrations/logcat/) |
| 1 | +### Timber |
4 | 2 |
|
5 | | -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). |
| 3 | +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`. |
| 4 | + |
| 5 | +If you want to customize these levels, please have a look at [Timber docs](/platforms/android/integrations/timber/#configure). |
| 6 | + |
| 7 | +If you are not using our Gradle plugin, please have a look at [Timber docs](/platforms/android/integrations/timber/#install). |
| 8 | + |
| 9 | +This snippet captures an intentional error, so you can test that logs are working as soon as you set it up: |
| 10 | + |
| 11 | +```kotlin |
| 12 | +import androidx.appcompat.app.AppCompatActivity |
| 13 | +import android.os.Bundle |
| 14 | +import java.lang.Exception |
| 15 | +import timber.log.Timber |
| 16 | + |
| 17 | +class MyActivity : AppCompatActivity() { |
| 18 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 19 | + super.onCreate(savedInstanceState) |
| 20 | + try { |
| 21 | + throw Exception("This is a test.") |
| 22 | + } catch (e: Exception) { |
| 23 | + Timber.e(e) |
| 24 | + } |
| 25 | + } |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +```java |
| 30 | +import androidx.appcompat.app.AppCompatActivity; |
| 31 | +import android.os.Bundle; |
| 32 | +import java.lang.Exception; |
| 33 | +import timber.log.Timber; |
| 34 | + |
| 35 | +public class MyActivity extends AppCompatActivity { |
| 36 | + protected void onCreate(Bundle savedInstanceState) { |
| 37 | + super.onCreate(savedInstanceState); |
| 38 | + try { |
| 39 | + throw new Exception("This is a test."); |
| 40 | + } catch (Exception e) { |
| 41 | + Timber.e(e); |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +### Logcat |
| 48 | + |
| 49 | +The Sentry Android Gradle Plugin automatically captures Logcat logs of level `WARNING` or higher. |
| 50 | + |
| 51 | +If you would like to change the minimum level, please have a look at [Logcat docs](/platforms/android/integrations/logcat/#configure). |
| 52 | + |
| 53 | +This snippet captures an intentional error, so you can test that everything is working once you've set it up: |
| 54 | + |
| 55 | +```kotlin |
| 56 | +import androidx.appcompat.app.AppCompatActivity |
| 57 | +import android.os.Bundle |
| 58 | +import io.sentry.Sentry |
| 59 | +import android.util.Log |
| 60 | + |
| 61 | +class MyActivity : AppCompatActivity() { |
| 62 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 63 | + super.onCreate(savedInstanceState) |
| 64 | + Log.w("MyTag", "Warning message.") |
| 65 | + |
| 66 | + Sentry.captureException(Exception("My Exception")) |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +```java |
| 72 | +import androidx.appcompat.app.AppCompatActivity; |
| 73 | +import android.os.Bundle; |
| 74 | +import java.lang.Exception; |
| 75 | +import io.sentry.Sentry; |
| 76 | +import android.util.Log; |
| 77 | + |
| 78 | +public class MyActivity extends AppCompatActivity { |
| 79 | + protected void onCreate(Bundle savedInstanceState) { |
| 80 | + super.onCreate(savedInstanceState); |
| 81 | + Log.w("MyTag", "Warning message."); |
| 82 | + |
| 83 | + Sentry.captureException(new Exception("My Exception")); |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
0 commit comments