Skip to content

Commit a14b1a8

Browse files
Android Logs docs without Errors / Breadcrumbs distractions (#14733)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR *Tell us what you're changing and why. If your PR **resolves an issue**, please link it so it closes automatically.* ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Stefano <[email protected]>
1 parent f310f3c commit a14b1a8

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

docs/platforms/android/integrations/timber/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ plugins {
3232

3333
Then, initialize the [Android SDK](/platforms/android/#configure).
3434

35-
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`.
35+
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`.
3636

3737
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.
3838

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,86 @@
1-
Available integrations:
2-
- [Timber](/platforms/android/integrations/timber/)
3-
- [Logcat](/platforms/android/integrations/logcat/)
1+
### Timber
42

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

Comments
 (0)