diff --git a/docs/get-started/guides/logs.mdx b/docs/get-started/guides/logs.mdx index 4040c6ee31049..23e8d614fb5bb 100644 --- a/docs/get-started/guides/logs.mdx +++ b/docs/get-started/guides/logs.mdx @@ -883,7 +883,6 @@ SentryAndroid.init(context) { options -> options.dsn = "..." options.environment = "development" options.tracesSampleRate = 1.0 // 100% of traces - options.logs.enabled = true } ``` diff --git a/docs/platforms/android/configuration/options.mdx b/docs/platforms/android/configuration/options.mdx index 0544cc1f82c6e..811db81c41a1d 100644 --- a/docs/platforms/android/configuration/options.mdx +++ b/docs/platforms/android/configuration/options.mdx @@ -450,9 +450,9 @@ Controls whether the SDK should propagate the W3C `traceparent` HTTP header alon - + -Set this boolean to `false` to disable tracing for `OPTIONS` requests. This option's default value will likely be changed in the next major version, meaning you will have to set it to `true` if you want to keep tracing `OPTIONS` requests. +By default, the SDK does not trace `OPTIONS` requests. Set this option to `true` to create transactions for them. diff --git a/docs/platforms/android/index.mdx b/docs/platforms/android/index.mdx index 54974cfc7d4b8..7a868d320c8bd 100644 --- a/docs/platforms/android/index.mdx +++ b/docs/platforms/android/index.mdx @@ -130,10 +130,6 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp - - - - @@ -142,6 +138,14 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp ``` + + + +Calls to `Sentry.logger()` send logs without additional configuration. To capture Timber or Logcat output automatically, enable log capture for the applicable logging integration. + + + + ## Verify Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes. diff --git a/docs/platforms/android/integrations/logcat/index.mdx b/docs/platforms/android/integrations/logcat/index.mdx index 983f5ba898393..5f4383c63d8b8 100644 --- a/docs/platforms/android/integrations/logcat/index.mdx +++ b/docs/platforms/android/integrations/logcat/index.mdx @@ -10,7 +10,7 @@ og_image: /og-images/platforms-android-integrations-logcat.png -This integration captures Logcat logs as breadcrumbs (great for error context!). But if you need to search and query your logs across your entire application, use Sentry Logs instead. Logcat logs at or above the `minLevel` are automatically sent as Sentry Logs when enabled. See the Support With Sentry Logs section below. +This integration captures Logcat logs as breadcrumbs (great for error context!). But if you need to search and query your logs across your entire application, use Sentry Logs instead. Logcat logs at or above the `minLevel` are sent as Sentry Logs when Logcat log capture is enabled. See the Support With Sentry Logs section below. @@ -135,4 +135,30 @@ Sentry Logs for Logcat are supported in Sentry Android SDK version `8.17.0` and -Logcat logs at or above the `minLevel` captured by Sentry are automatically sent as Sentry Logs, if enabled. +Automatic Sentry Logs capture from Logcat is disabled by default. Enable it in `AndroidManifest.xml`: + +```xml {filename:AndroidManifest.xml} + + + +``` + +Or enable it when initializing the SDK: + +```java {tabTitle:Java} +import io.sentry.android.core.SentryAndroid; + +SentryAndroid.init(this, options -> { + options.setLogcatLogCaptureEnabled(true); +}); +``` + +```kotlin {tabTitle:Kotlin} +import io.sentry.android.core.SentryAndroid + +SentryAndroid.init(this) { options -> + options.logcatLogCaptureEnabled = true +} +``` + +The Android Gradle plugin's `logcat.enabled` option controls Logcat bytecode instrumentation. `logcatLogCaptureEnabled` controls whether the instrumented records are also sent as Sentry Logs. diff --git a/docs/platforms/android/integrations/okhttp/index.mdx b/docs/platforms/android/integrations/okhttp/index.mdx index 003a1c2187e9d..c7335b38012c2 100644 --- a/docs/platforms/android/integrations/okhttp/index.mdx +++ b/docs/platforms/android/integrations/okhttp/index.mdx @@ -302,7 +302,7 @@ private final List failedRequestTargets = Collections.singletonList(".*" private final OkHttpClient client = new OkHttpClient.Builder() .eventListener(new SentryOkHttpEventListener()) .addInterceptor(new SentryOkHttpInterceptor( - Sentry.getCurrentHub(), + Sentry.getCurrentScopes(), null, true, codeRanges, @@ -340,7 +340,7 @@ private final List failedRequestTargets = Collections.singletonList(".*" private final OkHttpClient client = new OkHttpClient.Builder() .eventListener(new SentryOkHttpEventListener()) .addInterceptor(new SentryOkHttpInterceptor( - Sentry.getCurrentHub(), + Sentry.getCurrentScopes(), null, true, codeRanges, @@ -378,7 +378,7 @@ private final List failedRequestTargets = Collections.singletonList("mya private final OkHttpClient client = new OkHttpClient.Builder() .eventListener(new SentryOkHttpEventListener()) .addInterceptor(new SentryOkHttpInterceptor( - Sentry.getCurrentHub(), + Sentry.getCurrentScopes(), null, true, codeRanges, diff --git a/docs/platforms/android/integrations/timber/index.mdx b/docs/platforms/android/integrations/timber/index.mdx index 8e94f0151694d..29c8f24f463f5 100644 --- a/docs/platforms/android/integrations/timber/index.mdx +++ b/docs/platforms/android/integrations/timber/index.mdx @@ -8,7 +8,7 @@ description: "Learn more about the Sentry Timber integration for the Android SDK -This integration captures Timber logs as breadcrumbs and error events (great for error context!). But if you need to search and query your logs across your entire application, use Sentry Logs instead. Timber logs at or above the `minLogsLevel` are automatically sent as Sentry Logs when enabled. See the Support With Sentry Logs section below. +This integration captures Timber logs as breadcrumbs and error events (great for error context!). But if you need to search and query your logs across your entire application, use Sentry Logs instead. Timber logs at or above the `minLogsLevel` are sent as Sentry Logs when Timber log capture is enabled. See the Support With Sentry Logs section below. @@ -74,6 +74,8 @@ implementation 'io.sentry:sentry-android-timber:{{@inject packages.version('sent Configuration should happen as early as possible in your application's lifecycle. ```kotlin +import io.sentry.SentryLevel +import io.sentry.SentryLogLevel import io.sentry.android.core.SentryAndroid import io.sentry.android.timber.SentryTimberIntegration import timber.log.Timber @@ -90,7 +92,8 @@ SentryAndroid.init(this) { options -> SentryTimberIntegration( minEventLevel = SentryLevel.ERROR, minBreadcrumbLevel = SentryLevel.INFO, - minLogsLevel = SentryLogLevel.INFO + minLogsLevel = SentryLogLevel.INFO, + logsEnabled = false ) ) } else { @@ -100,9 +103,11 @@ SentryAndroid.init(this) { options -> ``` ```java +import io.sentry.SentryLevel; +import io.sentry.SentryLogLevel; import io.sentry.android.core.SentryAndroid; import io.sentry.android.timber.SentryTimberIntegration; -import timber.log.Timber +import timber.log.Timber; // import BuildConfig SentryAndroid.init(this, options -> { @@ -116,7 +121,8 @@ SentryAndroid.init(this, options -> { new SentryTimberIntegration( SentryLevel.ERROR, SentryLevel.INFO, - SentryLogLevel.INFO + SentryLogLevel.INFO, + false ) ); } else { @@ -181,4 +187,50 @@ Sentry Logs for Timber are supported in Sentry Android SDK version `8.17.0` and -Timber logs at or above the `minLogsLevel` captured by Sentry are automatically sent as Sentry Logs, if enabled. +Automatic Sentry Logs capture from Timber is disabled by default. + +For the auto-installed Timber integration, enable capture in `AndroidManifest.xml`: + +```xml {filename:AndroidManifest.xml} + + + +``` + +Or enable it when initializing the SDK: + +```java {tabTitle:Java} +import io.sentry.android.core.SentryAndroid; + +SentryAndroid.init(this, options -> { + options.setTimberLogCaptureEnabled(true); +}); +``` + +```kotlin {tabTitle:Kotlin} +import io.sentry.android.core.SentryAndroid + +SentryAndroid.init(this) { options -> + options.timberLogCaptureEnabled = true +} +``` + +When manually adding `SentryTimberIntegration`, pass `true` as its `logsEnabled` argument instead: + +```kotlin {tabTitle:Kotlin} +SentryTimberIntegration( + minEventLevel = SentryLevel.ERROR, + minBreadcrumbLevel = SentryLevel.INFO, + minLogsLevel = SentryLogLevel.INFO, + logsEnabled = true +) +``` + +```java {tabTitle:Java} +new SentryTimberIntegration( + SentryLevel.ERROR, + SentryLevel.INFO, + SentryLogLevel.INFO, + true +); +``` diff --git a/docs/platforms/android/manual-setup/index.mdx b/docs/platforms/android/manual-setup/index.mdx index 1e24b68875909..2fc621b6e6ea8 100644 --- a/docs/platforms/android/manual-setup/index.mdx +++ b/docs/platforms/android/manual-setup/index.mdx @@ -84,9 +84,6 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy --> - - - @@ -167,9 +164,6 @@ class MyApplication : Application() { // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS - // enable logs to be sent to Sentry. Use Sentry.logger() to capture logs or check the available integrations that capture logs automatically: https://docs.sentry.io/platforms/android/logs/#integrations - options.logs.isEnabled = true - // enable tombstone support for richer Native crashes context. See more at https://docs.sentry.io/platforms/android/configuration/tombstones/ options.isTombstoneEnabled = true @@ -226,9 +220,6 @@ public class MyApplication extends Application { // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy // options.getSessionReplay().setScreenshotStrategy(ScreenshotStrategyType.CANVAS); - // enable logs to be sent to Sentry. Use Sentry.logger() to capture logs or check the available integrations that capture logs automatically: https://docs.sentry.io/platforms/android/logs/#integrations - options.getLogs().setEnabled(true); - // enable tombstone support for richer Native crashes context. See more at https://docs.sentry.io/platforms/android/configuration/tombstones/ options.setTombstoneEnabled(true); diff --git a/docs/platforms/android/migration/v8-to-v9.mdx b/docs/platforms/android/migration/v8-to-v9.mdx new file mode 100644 index 0000000000000..623ada90f4c85 --- /dev/null +++ b/docs/platforms/android/migration/v8-to-v9.mdx @@ -0,0 +1,73 @@ +--- +title: Migrate from Sentry 8.x to 9.0.0 +description: "Learn how to migrate from Sentry Android SDK 8.x to 9.0.0." +sidebar_order: 8890 +--- + +Version 9 removes the deprecated Hub compatibility APIs and the global Logs and Metrics enable options. Migrate remaining Hub references to Scopes, then update your telemetry configuration. + +## Removed Hub APIs + +Version 8 deprecated Hub and introduced Scopes. Version 9 removes the Hub compatibility layer: + +- `IHub` has been removed. Use `IScopes` instead. +- `HubAdapter.getInstance()` has been removed. Use `ScopesAdapter.getInstance()` instead. +- `HubScopesWrapper` has been removed. Use the wrapped `IScopes` instance directly. +- `NoOpHub.getInstance()` has been removed. Use `NoOpScopes.getInstance()` instead. +- `Sentry.getCurrentHub()` and `Sentry.setCurrentHub(...)` have been removed. Use `Sentry.getCurrentScopes()` and `Sentry.setCurrentScopes(...)` instead. +- `IHub.clone()` and `IScopes.clone()` have been removed. Use `forkedScopes(...)` or `forkedCurrentScope(...)` when you need an independent Scopes instance. For temporary scope changes, use `withScope()` or `withIsolationScope()`. + +### Remove `popScope()` Calls + +`Sentry.popScope()` and `IScopes.popScope()` have been removed. Use `Sentry.withScope()` or `Sentry.withIsolationScope()` for temporary scope changes instead. Both methods restore the previous scopes after the callback finishes. + +### Scopes Model + +The Scopes model introduced in version 8 is the supported context model in version 9: + +- The global scope is attached to all events created by the SDK. To modify it before `SentryAndroid.init()`, call methods directly on `Sentry.getGlobalScope()`, such as `Sentry.getGlobalScope().setTag(...)`. +- The isolation scope attaches data to events within an isolated lifecycle. +- The current scope contains data for the active operation. Child scopes inherit its data, but parent scopes don't receive changes made in a child scope. + +On Android, APIs such as `Sentry.configureScope()` and `Sentry.setTag()` use the current scope by default. + +## Manual Logs and Metrics + +Calls to `Sentry.logger()` and `Sentry.metrics()` no longer require a global enable option. Remove calls to: + +- `options.getLogs().setEnabled(...)` +- `options.getMetrics().setEnabled(...)` + +The `beforeSendLog` and `beforeSendMetric` callbacks remain available for filtering or modifying telemetry. + +## Android Manifest Options + +Remove these manifest entries: + +```xml {filename:AndroidManifest.xml} + + +``` + +To capture logs from an automatic Android integration, use its integration-specific option instead: + +```xml {filename:AndroidManifest.xml} + + +``` + +The equivalent `SentryAndroidOptions` properties are `timberLogCaptureEnabled` and `logcatLogCaptureEnabled`. Both default to `false`. + +## Timber Constructor Changes + +Manual `SentryTimberIntegration` and `SentryTimberTree` construction now requires a `logsEnabled` argument. Pass `false` to keep automatic Sentry Logs capture disabled: + +```kotlin {tabTitle:Kotlin} +SentryTimberIntegration(logsEnabled = false) +``` + +```java {tabTitle:Java} +new SentryTimberIntegration(false); +``` + +Pass `true` only when Timber records should also be sent as Sentry Logs. diff --git a/docs/platforms/java/common/configuration/options.mdx b/docs/platforms/java/common/configuration/options.mdx index 28e28b75dcc17..5f2ede214e161 100644 --- a/docs/platforms/java/common/configuration/options.mdx +++ b/docs/platforms/java/common/configuration/options.mdx @@ -406,9 +406,9 @@ Controls whether the SDK should propagate the W3C `traceparent` HTTP header alon - + -Set this boolean to `false` to disable tracing for `OPTIONS` requests. This options default value will likely be changed in the next major version, meaning you will have to set it to `true` if you want to keep tracing `OPTIONS` requests. +By default, the SDK does not trace `OPTIONS` requests. Set this option to `true` to create transactions for them. diff --git a/docs/platforms/java/common/migration/8.x-to-9.0.mdx b/docs/platforms/java/common/migration/8.x-to-9.0.mdx new file mode 100644 index 0000000000000..932e2977a42c8 --- /dev/null +++ b/docs/platforms/java/common/migration/8.x-to-9.0.mdx @@ -0,0 +1,102 @@ +--- +title: Migrating Version 8.x to 9.0 +description: "Learn how to migrate from version 8.x to 9.0 of the Sentry Java SDK." +sidebar_order: 994 +--- + +Version 9 removes deprecated Hub compatibility and OpenTelemetry APIs, along with the global Logs and Metrics enable options. Migrate remaining Hub and OpenTelemetry references, then update your telemetry configuration. + +## Removed Hub APIs + +Version 8 deprecated Hub and introduced Scopes. Version 9 removes the Hub compatibility layer: + +- `IHub` has been removed. Use `IScopes` instead. +- `HubAdapter.getInstance()` has been removed. Use `ScopesAdapter.getInstance()` instead. +- `HubScopesWrapper` has been removed. Use the wrapped `IScopes` instance directly. +- `NoOpHub.getInstance()` has been removed. Use `NoOpScopes.getInstance()` instead. +- `Sentry.getCurrentHub()` and `Sentry.setCurrentHub(...)` have been removed. Use `Sentry.getCurrentScopes()` and `Sentry.setCurrentScopes(...)` instead. +- `IHub.clone()` and `IScopes.clone()` have been removed. Use `forkedScopes(...)` or `forkedCurrentScope(...)` when you need an independent Scopes instance. For temporary scope changes, use `pushScope()`, `pushIsolationScope()`, `withScope()`, or `withIsolationScope()`. +- Spring WebFlux's `SENTRY_HUB_KEY` has been removed. Use `SENTRY_SCOPES_KEY` instead. +- GraphQL's `ExceptionDetails.getHub()` has been removed. Use `ExceptionDetails.getScopes()` instead. + +### Remove `popScope()` Calls + +`Sentry.popScope()` and `IScopes.popScope()` have been removed. Close the lifecycle token returned by `pushScope()` or `pushIsolationScope()` to restore the previous scopes: + +```java +try (ISentryLifecycleToken ignored = Sentry.pushScope()) { + // This block has its own current scope. +} +``` + +Use the same pattern for an isolation scope: + +```java +try (ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) { + // This block has its own isolation scope. +} +``` + +If you can't use try-with-resources, close the token in a `finally` block. + +### Scopes Model + +The Scopes model introduced in version 8 is the supported context model in version 9: + +- The global scope is attached to all events created by the SDK. To modify it before `Sentry.init()`, call methods directly on `Sentry.getGlobalScope()`, such as `Sentry.getGlobalScope().setTag(...)`. +- The isolation scope attaches data to events within an isolated lifecycle, such as an incoming request. The SDK automatically forks this scope for incoming requests, CRON jobs, Spring `@Async`, and other integrations. +- The current scope contains data for the active operation. Child scopes inherit its data, but parent scopes don't receive changes made in a child scope. + +For backend and other JVM applications, APIs such as `Sentry.configureScope()` and `Sentry.setTag()` use the isolation scope by default. + +## Removed OpenTelemetry APIs + +Version 9 removes these deprecated OpenTelemetry integration classes: + +- `SentrySpanProcessor` +- `SentryPropagator` +- `OpenTelemetryLinkErrorEventProcessor` +- `Instrumenter`, including its `SentryOptions` option, `SpanContext` property, and `startChild` overloads +- `SentrySpanStorage` (internal) +- `TraceData` (internal) + +See the OpenTelemetry documentation for supported setup options. + +## Manual Logs and Metrics + +Calls to `Sentry.logger()` and `Sentry.metrics()` no longer require a global enable option. Remove calls to: + +- `options.getLogs().setEnabled(...)` +- `options.getMetrics().setEnabled(...)` + +The `beforeSendLog` and `beforeSendMetric` callbacks remain available for filtering or modifying telemetry. + +## Removed External Configuration + +Remove these options from your configuration: + +| Configuration | Removed Logs Option | Removed Metrics Option | +| -------------------- | --------------------- | ------------------------ | +| `sentry.properties` | `logs.enabled` | `metrics.enabled` | +| Java system property | `sentry.logs.enabled` | `sentry.metrics.enabled` | +| Environment variable | `SENTRY_LOGS_ENABLED` | `SENTRY_METRICS_ENABLED` | +| Spring Boot | `sentry.logs.enabled` | `sentry.metrics.enabled` | + +Metrics are sent only when your application calls `Sentry.metrics()`. To discard selected metrics, use `beforeSendMetric`. + +## Automatic Logging Integrations + +Automatic Sentry Logs capture is disabled by default. Enable it on each logging integration that should forward records: + +| Integration | Version 9 Opt-In | +| -------------------------------------- | --------------------------------------------------------- | +| Logback | Set `true` on `SentryAppender` | +| Log4j 2 | Set `logsEnabled="true"` on the `` appender | +| `java.util.logging` | Set `io.sentry.jul.SentryHandler.logsEnabled=true` | +| Spring Boot logging auto-configuration | Set `sentry.logging.logs-enabled=true` | + +The minimum-level options only select eligible records. They do not enable Sentry Logs capture. + +## Constructor Changes + +The Log4j 2 `SentryAppender` constructor and `createAppender` factory now require a `logsEnabled` argument. Pass `true` to capture Sentry Logs or `false` to keep capture disabled. The deprecated constructor without `minimumLevel` has been removed. diff --git a/docs/platforms/java/guides/jul/configuration/configuration-example.mdx b/docs/platforms/java/guides/jul/configuration/configuration-example.mdx index 674fdf1e6cb1f..12c9151768a98 100644 --- a/docs/platforms/java/guides/jul/configuration/configuration-example.mdx +++ b/docs/platforms/java/guides/jul/configuration/configuration-example.mdx @@ -14,5 +14,7 @@ Configuration options specific to `java.util.logging` integration can be configu io.sentry.jul.SentryHandler.level=CONFIG io.sentry.jul.SentryHandler.minimumEventLevel=INFO io.sentry.jul.SentryHandler.minimumBreadcrumbLevel=CONFIG +io.sentry.jul.SentryHandler.logsEnabled=true +io.sentry.jul.SentryHandler.minimumLevel=CONFIG io.sentry.jul.SentryHandler.printfStyle=true ``` diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx index e5f5e55e960cc..3f5f5b4f860b2 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx @@ -7,7 +7,7 @@ For the best experience, we recommend using Sentry's Spring Boot integration wit -By default this integration captures logs as breadcrumbs and error events (great for error context!). But if you need to search and query your logs across your entire application, we recommend enabling the new logs feature. Logs at or above the `minimumLevel` are automatically sent as Sentry Logs when enabled. +By default this integration captures logs as breadcrumbs and error events (great for error context!). To search and query logs across your application, enable Sentry Logs capture with `sentry.logging.logs-enabled`. Records at or above `minimumLevel` are then sent as Sentry Logs. @@ -39,10 +39,10 @@ For other dependency managers see the [central Maven repository](https://search. ### Spring Boot Configuration -To send logs to Sentry and have them show up in the Logs section, you need to enable the feature: +To send Log4j 2 records to Sentry Logs, enable log capture for the auto-configured appender: ```properties -sentry.logs.enabled=true +sentry.logging.logs-enabled=true ``` For Spring Boot 3 and 4, Sentry can register `SentryAppender` for you once the application context refreshes. This auto-configuration is opt-in: @@ -88,7 +88,7 @@ Spring Boot 2 doesn't support `SentryAppender` auto-configuration, and errors lo - + diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx index 273979e2b298a..4a5e29f2a6366 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx @@ -9,7 +9,7 @@ For the best experience, we recommend using Sentry's Spring Boot integration wit -By default this integration captures logs as breadcrumbs and error events (great for error context!). But if you need to search and query your logs across your entire application, we recommend enabling the new logs feature. Logs at or above the `sentry.logging.minimum-level` are automatically sent as Sentry Logs when enabled. +By default this integration captures logs as breadcrumbs and error events (great for error context!). To search and query logs across your application, enable Sentry Logs capture with `sentry.logging.logs-enabled`. Records at or above `sentry.logging.minimum-level` are then sent as Sentry Logs. @@ -33,10 +33,10 @@ implementation 'io.sentry:sentry-logback:{{@inject packages.version('sentry.java ### Spring Boot Configuration -To send logs to Sentry and have them show up in the Logs section, you need to enable the feature: +To send Logback records to Sentry Logs, enable log capture for the auto-configured appender: ```properties -sentry.logs.enabled=true +sentry.logging.logs-enabled=true ``` Minimum logging levels for `SentryAppender` can be configured in `application.properties` or `application.yml` file. @@ -70,6 +70,7 @@ If you decide to opt-out from the `application.properties` based Spring Boot log + true INFO diff --git a/docs/platforms/java/guides/spring/advanced-usage.mdx b/docs/platforms/java/guides/spring/advanced-usage.mdx index 9b0117afbae0f..15b6d5a068a43 100644 --- a/docs/platforms/java/guides/spring/advanced-usage.mdx +++ b/docs/platforms/java/guides/spring/advanced-usage.mdx @@ -22,7 +22,7 @@ Configuring this field activates the - + + logsEnabled="true" + + /> @@ -40,7 +45,11 @@ The `ConsoleAppender` is provided only as an example of a non-Sentry appender se - + + logsEnabled="true" + + /> @@ -72,9 +81,6 @@ If the DSN is not present in the `log4j2.xml` configuration, Sentry will attempt # https://docs.sentry.io/platforms/java/guides/log4j2/data-management/data-collected/ data-collection.user-info=false # Configure other data categories here. -// ___PRODUCT_OPTION_START___ logs -logs.enabled=true -// ___PRODUCT_OPTION_END___ logs ``` @@ -105,6 +111,7 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi minimumBreadcrumbLevel="DEBUG" minimumEventLevel="WARN" + logsEnabled="true" minimumLevel="DEBUG" /> @@ -118,6 +125,7 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi minimumBreadcrumbLevel="DEBUG" minimumEventLevel="WARN" + logsEnabled="true" minimumLevel="DEBUG" /> diff --git a/platform-includes/getting-started-config/java.logback.mdx b/platform-includes/getting-started-config/java.logback.mdx index c68dff686d876..0a4085c3a9893 100644 --- a/platform-includes/getting-started-config/java.logback.mdx +++ b/platform-includes/getting-started-config/java.logback.mdx @@ -20,13 +20,9 @@ The `ConsoleAppender` is provided only as an example of a non-Sentry appender se - - // ___PRODUCT_OPTION_START___ logs - - true - - // ___PRODUCT_OPTION_END___ logs - + // ___PRODUCT_OPTION_START___ logs + true + // ___PRODUCT_OPTION_END___ logs - + + // ___PRODUCT_OPTION_START___ logs + true + // ___PRODUCT_OPTION_END___ logs + @@ -105,7 +105,8 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi DEBUG // ___PRODUCT_OPTION_START___ logs - + + true DEBUG // ___PRODUCT_OPTION_END___ logs @@ -120,7 +121,8 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi DEBUG // ___PRODUCT_OPTION_START___ logs - + + true DEBUG // ___PRODUCT_OPTION_END___ logs diff --git a/platform-includes/getting-started-config/java.mdx b/platform-includes/getting-started-config/java.mdx index 2acface3c9a9e..a50668ac0c581 100644 --- a/platform-includes/getting-started-config/java.mdx +++ b/platform-includes/getting-started-config/java.mdx @@ -25,11 +25,6 @@ Sentry.init(options -> { options.setProfileSessionSampleRate(1.0); options.setProfileLifecycle(ProfileLifecycle.TRACE); // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.getLogs().setEnabled(true); - // ___PRODUCT_OPTION_END___ logs }); ``` @@ -57,11 +52,6 @@ Sentry.init { options -> options.profileSessionSampleRate = 1.0 options.profileLifecycle = ProfileLifecycle.TRACE // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.logs.enabled = true - // ___PRODUCT_OPTION_END___ logs } ``` diff --git a/platform-includes/getting-started-config/java.servlet.mdx b/platform-includes/getting-started-config/java.servlet.mdx index cbcc3debdb2e1..ee0e738bec21e 100644 --- a/platform-includes/getting-started-config/java.servlet.mdx +++ b/platform-includes/getting-started-config/java.servlet.mdx @@ -36,11 +36,6 @@ public final class SentryInitializer implements ServletContainerInitializer { options.setProfileSessionSampleRate(1.0); options.setProfileLifecycle(ProfileLifecycle.TRACE); // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.getLogs().setEnabled(true); - // ___PRODUCT_OPTION_END___ logs }); } } @@ -77,11 +72,6 @@ class SentryInitializer : ServletContainerInitializer { options.profileSessionSampleRate = 1.0 options.profileLifecycle = ProfileLifecycle.TRACE // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.logs.enabled = true - // ___PRODUCT_OPTION_END___ logs } } } diff --git a/platform-includes/getting-started-config/java.spring-boot.mdx b/platform-includes/getting-started-config/java.spring-boot.mdx index 83df69f0e8d54..43fe0202e6496 100644 --- a/platform-includes/getting-started-config/java.spring-boot.mdx +++ b/platform-includes/getting-started-config/java.spring-boot.mdx @@ -25,8 +25,8 @@ sentry.profile-lifecycle=TRACE // ___PRODUCT_OPTION_END___ profiling // ___PRODUCT_OPTION_START___ logs -# Enable logs -sentry.logs.enabled=true +# Enable automatic Sentry Logs capture from the configured logging framework +sentry.logging.logs-enabled=true // ___PRODUCT_OPTION_END___ logs ``` @@ -54,9 +54,9 @@ sentry: // ___PRODUCT_OPTION_END___ profiling // ___PRODUCT_OPTION_START___ logs - # Enable logs - logs: - enabled: true + # Enable automatic Sentry Logs capture from the configured logging framework + logging: + logs-enabled: true // ___PRODUCT_OPTION_END___ logs ``` diff --git a/platform-includes/getting-started-config/java.spring.mdx b/platform-includes/getting-started-config/java.spring.mdx index b0682f6a21e83..4af66bfdd7712 100644 --- a/platform-includes/getting-started-config/java.spring.mdx +++ b/platform-includes/getting-started-config/java.spring.mdx @@ -175,8 +175,12 @@ traces-sample-rate=1.0 profile-session-sample-rate=1.0 profile-lifecycle=TRACE // ___PRODUCT_OPTION_END___ profiling -// ___PRODUCT_OPTION_START___ logs -# Enable logs -logs.enabled=true -// ___PRODUCT_OPTION_END___ logs ``` + + + + +You can use the `Sentry.logger()` APIs to manually send logs within your application code. The SDK also supports popular logging frameworks to record logs automatically, see the logging integration page for more details. + + + diff --git a/platform-includes/getting-started-config/opentelemetry/java.mdx b/platform-includes/getting-started-config/opentelemetry/java.mdx index 083b36ef8c2eb..b2e5215806ab1 100644 --- a/platform-includes/getting-started-config/opentelemetry/java.mdx +++ b/platform-includes/getting-started-config/opentelemetry/java.mdx @@ -11,9 +11,6 @@ data-collection.user-info=false # ___PRODUCT_OPTION_START___ performance traces-sample-rate=1.0 # ___PRODUCT_OPTION_END___ performance -// ___PRODUCT_OPTION_START___ logs -logs.enabled=true -// ___PRODUCT_OPTION_END___ logs // ___PRODUCT_OPTION_START___ profiling # Enable profiling diff --git a/platform-includes/logs/setup/android.mdx b/platform-includes/logs/setup/android.mdx index 7a231888ad31a..a103de99af0d5 100644 --- a/platform-includes/logs/setup/android.mdx +++ b/platform-includes/logs/setup/android.mdx @@ -1,38 +1,3 @@ -To enable logging integrations, you need to initialize the SDK with the `logs.enabled` option set to `true`. Since SDK version 8.59.0, direct `Sentry.logger()` calls don't require this option. +After you initialize the SDK, calls to `Sentry.logger()` send logs without additional configuration. -```XML {filename:AndroidManifest.xml} - -``` - -```java {tabTitle: Java} {10} -import io.sentry.SentryLevel; -import io.sentry.android.core.SentryAndroid; -import android.app.Application; - -public class MyApplication extends Application { - public void onCreate() { - super.onCreate(); - SentryAndroid.init(this, options -> { - options.setDsn("___PUBLIC_DSN___"); - options.getLogs().setEnabled(true); - }); - } -} -``` - -```kotlin {tabTitle: Kotlin} {11} -import io.sentry.android.core.SentryAndroid -import io.sentry.SentryOptions.BeforeSendCallback -import io.sentry.Hint -import android.app.Application - -class MyApplication : Application() { - override fun onCreate() { - super.onCreate() - SentryAndroid.init(this) { options -> - options.dsn = "___PUBLIC_DSN___" - options.logs.enabled = true - } - } -} -``` +To capture Timber or Logcat output automatically, enable log capture for the applicable logging integration. diff --git a/platform-includes/logs/setup/java.jul.mdx b/platform-includes/logs/setup/java.jul.mdx index 5ecd3ab817ad6..7ced10ab35183 100644 --- a/platform-includes/logs/setup/java.jul.mdx +++ b/platform-includes/logs/setup/java.jul.mdx @@ -1,32 +1,12 @@ -To enable logging, you need to configure the option in `sentry.properties` or when calling `Sentry.init`. +Enable Sentry Logs on the handler with `logsEnabled`. Use `minimumLevel` to configure which log messages are sent to Sentry. -```properties {tabTitle: sentry.properties} {mdExpandTabs} -logs.enabled=true -``` - -```java {tabTitle: Sentry.init (Java)} {5} -import io.sentry.Sentry; - -Sentry.init(options -> { - options.setDsn("___PUBLIC_DSN___"); - options.getLogs().setEnabled(true); -}); -``` - -```kotlin {tabTitle: Sentry.init(Kotlin)} {5} -import io.sentry.Sentry - -Sentry.init { options -> - options.dsn = "___PUBLIC_DSN___" - options.logs.enabled = true -} -``` - -You may also configure the Sentry handler and set `minimumLevel` in `logging.properties`: - -```properties {tabTitle: logging.properties} {5} +```properties {tabTitle: logging.properties} {5,8} # Configure the Sentry handler handlers=io.sentry.jul.SentryHandler -# Set the minimum level for Sentry handler -io.sentry.jul.SentryHandler.minimumLevel=CONFIG \ No newline at end of file +# Enable Sentry Logs capture +io.sentry.jul.SentryHandler.logsEnabled=true + +# Set the minimum level for the Sentry handler +io.sentry.jul.SentryHandler.minimumLevel=CONFIG +``` diff --git a/platform-includes/logs/setup/java.log4j2.mdx b/platform-includes/logs/setup/java.log4j2.mdx index 18b9dd50add33..d9988114279a7 100644 --- a/platform-includes/logs/setup/java.log4j2.mdx +++ b/platform-includes/logs/setup/java.log4j2.mdx @@ -1,35 +1,12 @@ -To enable logging, you need to configure the option in `sentry.properties` or when calling `Sentry.init`. +Enable Sentry Logs on the appender with `logsEnabled`. Use `minimumLevel` to configure which log messages are sent to Sentry. -```properties {tabTitle: sentry.properties} {mdExpandTabs} -logs.enabled=true -``` - -```java {tabTitle: Sentry.init (Java)} {5} -import io.sentry.Sentry; - -Sentry.init(options -> { - options.setDsn("___PUBLIC_DSN___"); - options.getLogs().setEnabled(true); -}); -``` - -```kotlin {tabTitle: Sentry.init(Kotlin)} {5} -import io.sentry.Sentry - -Sentry.init { options -> - options.dsn = "___PUBLIC_DSN___" - options.logs.enabled = true -} -``` - -You may also set `minimumLevel` in `log4j2.xml` to configure which log messages are sent to Sentry. - -```xml {tabTitle: log4j2.xml} {6} +```xml {tabTitle: log4j2.xml} {4,7} -``` \ No newline at end of file +``` diff --git a/platform-includes/logs/setup/java.logback.mdx b/platform-includes/logs/setup/java.logback.mdx index cdb064e0dd0de..39dfa8717119e 100644 --- a/platform-includes/logs/setup/java.logback.mdx +++ b/platform-includes/logs/setup/java.logback.mdx @@ -1,14 +1,12 @@ -To enable logging, you need to configure the option in the appender configuration. You may also set `minimumLevel` to configure which log messages are sent to Sentry. +Enable Sentry Logs on the appender with `logsEnabled`. Use `minimumLevel` to configure which log messages are sent to Sentry. -```xml {tabTitle: logback.xml} {5-7,15} +```xml {tabTitle: logback.xml} {7,15} ___PUBLIC_DSN___ - - true - + true WARN @@ -17,4 +15,4 @@ To enable logging, you need to configure the option in the appender configuratio DEBUG -``` \ No newline at end of file +``` diff --git a/platform-includes/logs/setup/java.mdx b/platform-includes/logs/setup/java.mdx index c7ded08d2531d..a7fc3bad37e5d 100644 --- a/platform-includes/logs/setup/java.mdx +++ b/platform-includes/logs/setup/java.mdx @@ -1,19 +1 @@ -To enable logging integrations, you need to initialize the SDK with the `logs.enabled` option set to `true`. Since SDK version 8.59.0, direct `Sentry.logger()` calls don't require this option. - -```java {tabTitle: Java} {5} -import io.sentry.Sentry; - -Sentry.init(options -> { - options.setDsn("___PUBLIC_DSN___"); - options.getLogs().setEnabled(true); -}); -``` - -```kotlin {tabTitle: Kotlin} {5} -import io.sentry.Sentry - -Sentry.init { options -> - options.dsn = "___PUBLIC_DSN___" - options.logs.enabled = true -} -``` +After you initialize the SDK, calls to `Sentry.logger()` send logs without additional configuration. diff --git a/platform-includes/logs/setup/java.spring-boot.mdx b/platform-includes/logs/setup/java.spring-boot.mdx index abebb20eeb97c..65083266b955a 100644 --- a/platform-includes/logs/setup/java.spring-boot.mdx +++ b/platform-includes/logs/setup/java.spring-boot.mdx @@ -1,10 +1,11 @@ -To enable logging, you have to enable the feature in your Spring configuration file: +Enable automatic Sentry Logs capture for the configured logging framework with `sentry.logging.logs-enabled`: ```properties {tabTitle:application.properties} -sentry.logs.enabled=true +sentry.logging.logs-enabled=true ``` ```yaml {tabTitle:application.yml} sentry: - logs.enabled: true -``` \ No newline at end of file + logging: + logs-enabled: true +``` diff --git a/platform-includes/logs/usage/android.mdx b/platform-includes/logs/usage/android.mdx index 3991f3a7af959..9ed4bebf0ac9c 100644 --- a/platform-includes/logs/usage/android.mdx +++ b/platform-includes/logs/usage/android.mdx @@ -1,4 +1,4 @@ -Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `Sentry.logger()` APIs. +Once the SDK is initialized, you can send logs using the `Sentry.logger()` APIs without enabling an additional option. The `Sentry.logger()` namespace exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warn`, `error`, and `fatal`. diff --git a/platform-includes/logs/usage/java.jul.mdx b/platform-includes/logs/usage/java.jul.mdx index 2f63102e77785..016de1be5b8af 100644 --- a/platform-includes/logs/usage/java.jul.mdx +++ b/platform-includes/logs/usage/java.jul.mdx @@ -1 +1 @@ -Once the handler is configured with logging enabled, any logs at or above the `minimumLevel` will be sent to Sentry. \ No newline at end of file +After you set `io.sentry.jul.SentryHandler.logsEnabled=true`, records at or above `minimumLevel` are sent as Sentry Logs. diff --git a/platform-includes/logs/usage/java.log4j2.mdx b/platform-includes/logs/usage/java.log4j2.mdx index 2f63102e77785..d9ee5f66cf52f 100644 --- a/platform-includes/logs/usage/java.log4j2.mdx +++ b/platform-includes/logs/usage/java.log4j2.mdx @@ -1 +1 @@ -Once the handler is configured with logging enabled, any logs at or above the `minimumLevel` will be sent to Sentry. \ No newline at end of file +After you set `logsEnabled="true"` on the appender, records at or above `minimumLevel` are sent as Sentry Logs. diff --git a/platform-includes/logs/usage/java.logback.mdx b/platform-includes/logs/usage/java.logback.mdx index 4c3f1b96cb6a3..42dee74476dc1 100644 --- a/platform-includes/logs/usage/java.logback.mdx +++ b/platform-includes/logs/usage/java.logback.mdx @@ -1 +1 @@ -Once the appender has been configured with logs enabled any logs equal to or higher than `minimumLevel` will be sent to Sentry as logs. \ No newline at end of file +After you set `logsEnabled` to `true` on the appender, records at or above `minimumLevel` are sent as Sentry Logs. diff --git a/platform-includes/logs/usage/java.mdx b/platform-includes/logs/usage/java.mdx index a0233f9b5deb6..998c0046cb8b9 100644 --- a/platform-includes/logs/usage/java.mdx +++ b/platform-includes/logs/usage/java.mdx @@ -1,4 +1,4 @@ -Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `Sentry.logger()` APIs. +Once the SDK is initialized, you can send logs using the `Sentry.logger()` APIs without enabling an additional option. The `Sentry.logger()` namespace exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warn`, `error`, and `fatal`. diff --git a/platform-includes/metrics/options/android.mdx b/platform-includes/metrics/options/android.mdx index 035acd2d5b881..bb5ddc1807fab 100644 --- a/platform-includes/metrics/options/android.mdx +++ b/platform-includes/metrics/options/android.mdx @@ -1,4 +1,4 @@ -The Sentry Android SDK provides several options to configure how metrics are captured and sent to Sentry. +The Sentry Android SDK provides several options to configure how metrics are captured and sent to Sentry. Calls to `Sentry.metrics()` send metrics whenever the SDK is enabled; there is no global Metrics enable option. ### Filtering and Modifying Metrics @@ -55,31 +55,3 @@ SentryAndroid.init(context) { options -> } } ``` - -### Disabling Metrics - -Since SDK version 8.59.0, the `metrics.enabled` flag no longer affects metrics; use `beforeSend` to drop them instead. In older versions, you can disable metrics collection entirely by disabling the `metrics.enabled` flag: - -```xml {tabTitle: XML} {mdExpandTabs} - -``` -```java {tabTitle: Java} -import io.sentry.android.core.SentryAndroid; -import io.sentry.android.core.SentryAndroidOptions; - -SentryAndroid.init(context, - options -> { - // ... - options.getMetrics().setEnabled(false); - } -); -``` -```kotlin {tabTitle: Kotlin} -import io.sentry.android.core.SentryAndroid -import io.sentry.android.core.SentryAndroidOptions - -SentryAndroid.init { options -> - // ... - options.metrics.setEnabled(false) -} -``` diff --git a/platform-includes/metrics/options/java.mdx b/platform-includes/metrics/options/java.mdx index 90917554880cf..3e0957292b6df 100644 --- a/platform-includes/metrics/options/java.mdx +++ b/platform-includes/metrics/options/java.mdx @@ -1,4 +1,4 @@ -The Sentry Java SDK provides several options to configure how metrics are captured and sent to Sentry. +The Sentry Java SDK provides several options to configure how metrics are captured and sent to Sentry. Calls to `Sentry.metrics()` send metrics whenever the SDK is enabled; there is no global Metrics enable option. ### Filtering and Modifying Metrics @@ -53,26 +53,3 @@ Sentry.init { options -> } } ``` - -### Disabling Metrics - -Since SDK version 8.59.0, the `metrics.enabled` flag no longer affects metrics; use `beforeSend` to drop them instead. In older versions, you can disable metrics collection entirely by disabling the `metrics.enabled` flag: - -```java {tabTitle: Java} -import io.sentry.Sentry; - -Sentry.init( - options -> { - // ... - options.getMetrics().setEnabled(false); - } -); -``` -```kotlin {tabTitle: Kotlin} -import io.sentry.Sentry - -Sentry.init { options -> - // ... - options.metrics.setEnabled(false) -} -``` \ No newline at end of file diff --git a/platform-includes/metrics/options/java.spring-boot.mdx b/platform-includes/metrics/options/java.spring-boot.mdx index 25f84c84c0500..b94414f54fbe4 100644 --- a/platform-includes/metrics/options/java.spring-boot.mdx +++ b/platform-includes/metrics/options/java.spring-boot.mdx @@ -56,17 +56,6 @@ class SentryMetricsConfiguration { } ``` -The `beforeSend` function receives a metric object, and should return the metric object if you want it to be sent to Sentry, or `null` if you want to discard it. +The `beforeSend` function receives a metric object. Return the metric to send it to Sentry, or return `null` to discard it. -### Disabling Metrics - -Since SDK version 8.59.0, the `metrics.enabled` flag no longer affects metrics; use `beforeSend` to drop them instead. In older versions, you can disable metrics collection entirely by disabling the `metrics.enabled` flag: - -```properties {tabTitle:application.properties} -sentry.metrics.enabled=false -``` -```yaml {tabTitle:application.yml} -sentry: - metrics: - enabled: false -``` +Calls to `Sentry.metrics()` send metrics whenever the SDK is enabled; there is no global Metrics enable option.