From d8b77e729fc12b36a5fd358c61cb4e58149352a9 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 13 Aug 2026 15:21:42 +0200 Subject: [PATCH 01/10] fix(core): Make enable-flag warnings visible Initialize the fatal logger before external configuration is merged and route legacy Logs and Metrics migration warnings through the always-visible startup logger across core, Android, and Spring Boot. Co-Authored-By: Claude --- .../android/core/ManifestMetadataReader.java | 44 +++++++----- .../core/AndroidOptionsInitializerTest.kt | 22 ++++++ .../core/ManifestMetadataReaderTest.kt | 45 +++++------- .../spring/boot4/SentryAutoConfiguration.java | 8 +-- .../boot4/SentryAutoConfigurationTest.kt | 28 ++++---- .../boot/jakarta/SentryAutoConfiguration.java | 8 +-- .../jakarta/SentryAutoConfigurationTest.kt | 28 ++++---- .../spring/boot/SentryAutoConfiguration.java | 8 +-- .../boot/SentryAutoConfigurationTest.kt | 28 ++++---- sentry/src/main/java/io/sentry/Sentry.java | 2 +- .../main/java/io/sentry/SentryOptions.java | 8 +-- .../test/java/io/sentry/SentryOptionsTest.kt | 68 ++++++------------- sentry/src/test/java/io/sentry/SentryTest.kt | 30 ++++++++ 13 files changed, 172 insertions(+), 155 deletions(-) diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java index 0a4ed051bf7..d94d2aa72ab 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java @@ -709,32 +709,40 @@ static void applyMetadata( if (metadata.containsKey(ENABLE_LOGS)) { final boolean enableLogs = readBool(metadata, logger, ENABLE_LOGS, false); if (enableLogs) { - logger.log( - SentryLevel.WARNING, - "The Android manifest option 'io.sentry.logs.enabled' is no longer supported. " - + "Manual Sentry.logger() calls no longer require it, and automatic logging " - + "integrations now require their own opt-ins."); + options + .getFatalLogger() + .log( + SentryLevel.WARNING, + "The Android manifest option 'io.sentry.logs.enabled' is no longer supported. " + + "Manual Sentry.logger() calls no longer require it, and automatic logging " + + "integrations now require their own opt-ins."); } else { - logger.log( - SentryLevel.WARNING, - "The Android manifest option 'io.sentry.logs.enabled' no longer disables manual " - + "Sentry.logger() calls. Automatic logging integrations remain disabled " - + "unless enabled through their own opt-ins."); + options + .getFatalLogger() + .log( + SentryLevel.WARNING, + "The Android manifest option 'io.sentry.logs.enabled' no longer disables manual " + + "Sentry.logger() calls. Automatic logging integrations remain disabled " + + "unless enabled through their own opt-ins."); } } if (metadata.containsKey(ENABLE_METRICS)) { final boolean enableMetrics = readBool(metadata, logger, ENABLE_METRICS, false); if (enableMetrics) { - logger.log( - SentryLevel.WARNING, - "The Android manifest option 'io.sentry.metrics.enabled' is no longer supported. " - + "Manual Sentry.metrics() calls no longer require it."); + options + .getFatalLogger() + .log( + SentryLevel.WARNING, + "The Android manifest option 'io.sentry.metrics.enabled' is no longer supported. " + + "Manual Sentry.metrics() calls no longer require it."); } else { - logger.log( - SentryLevel.WARNING, - "The Android manifest option 'io.sentry.metrics.enabled' no longer disables " - + "manual Sentry.metrics() calls."); + options + .getFatalLogger() + .log( + SentryLevel.WARNING, + "The Android manifest option 'io.sentry.metrics.enabled' no longer disables " + + "manual Sentry.metrics() calls."); } } diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt index 224b66bbfb1..894ea9dfa4b 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.res.AssetManager import android.os.Build import android.os.Bundle +import android.util.Log import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import io.sentry.CompositePerformanceCollector @@ -58,6 +59,7 @@ import org.mockito.kotlin.spy import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.robolectric.annotation.Config +import org.robolectric.shadows.ShadowLog @RunWith(AndroidJUnit4::class) class AndroidOptionsInitializerTest { @@ -203,6 +205,26 @@ class AndroidOptionsInitializerTest { assertTrue(innerLogger.get(loggerField) is AndroidLogger) } + @Test + fun `legacy manifest warning is visible when debug is disabled`() { + ShadowLog.clear() + + fixture.initSut( + metadata = + Bundle().apply { + putString(ManifestMetadataReader.DSN, "https://key@sentry.io/123") + putBoolean(ManifestMetadataReader.ENABLE_LOGS, true) + }, + hasAppContext = false, + ) + + assertTrue( + ShadowLog.getLogsForTag("Sentry").any { + it.type == Log.ASSERT && it.msg.contains("'io.sentry.logs.enabled' is no longer supported") + } + ) + } + @Test fun `flush timeout is set to Android specific default value`() { fixture.initSut() diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt index e5b2f1fcd0b..df361b0de1d 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt @@ -32,7 +32,12 @@ import org.mockito.kotlin.verify class ManifestMetadataReaderTest { private class Fixture { val logger = mock() - val options = SentryAndroidOptions().apply { setLogger(this@Fixture.logger) } + val fatalLogger = mock() + val options = + SentryAndroidOptions().apply { + setLogger(this@Fixture.logger) + setFatalLogger(this@Fixture.fatalLogger) + } val buildInfoProvider = mock() fun getContext(metaData: Bundle = Bundle()): Context = @@ -1948,26 +1953,21 @@ class ManifestMetadataReaderTest { @Test fun `applyMetadata does not warn when legacy logs enabled metadata is absent`() { - fixture.options.isDebug = true val context = fixture.getContext() ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - verify(fixture.logger, never()).log(eq(SentryLevel.WARNING), any()) + verify(fixture.fatalLogger, never()).log(eq(SentryLevel.WARNING), any()) } @Test fun `applyMetadata warns when legacy logs enabled metadata is true`() { - val bundle = - bundleOf( - ManifestMetadataReader.DEBUG to true, - ManifestMetadataReader.ENABLE_LOGS to true, - ) + val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGS to true) val context = fixture.getContext(metaData = bundle) ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - verify(fixture.logger) + verify(fixture.fatalLogger) .log( SentryLevel.WARNING, "The Android manifest option 'io.sentry.logs.enabled' is no longer supported. " + @@ -1983,16 +1983,12 @@ class ManifestMetadataReaderTest { fun `applyMetadata warns when legacy logs enabled metadata is false`() { fixture.options.isEnableTimberLogs = true fixture.options.isEnableLogcatLogs = true - val bundle = - bundleOf( - ManifestMetadataReader.DEBUG to true, - ManifestMetadataReader.ENABLE_LOGS to false, - ) + val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGS to false) val context = fixture.getContext(metaData = bundle) ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - verify(fixture.logger) + verify(fixture.fatalLogger) .log( SentryLevel.WARNING, "The Android manifest option 'io.sentry.logs.enabled' no longer disables manual " + @@ -2055,21 +2051,16 @@ class ManifestMetadataReaderTest { @Test fun `applyMetadata does not warn when legacy metrics enabled metadata is absent`() { - fixture.options.isDebug = true val context = fixture.getContext() ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - verify(fixture.logger, never()).log(eq(SentryLevel.WARNING), any()) + verify(fixture.fatalLogger, never()).log(eq(SentryLevel.WARNING), any()) } @Test fun `applyMetadata warns when legacy metrics enabled metadata is true`() { - val bundle = - bundleOf( - ManifestMetadataReader.DEBUG to true, - ManifestMetadataReader.ENABLE_METRICS to true, - ) + val bundle = bundleOf(ManifestMetadataReader.ENABLE_METRICS to true) val context = fixture.getContext(metaData = bundle) val client = createSentryClientMock() @@ -2078,7 +2069,7 @@ class ManifestMetadataReaderTest { val scopes = createTestScopes(fixture.options).also { it.bindClient(client) } scopes.metrics().count("metric name") - verify(fixture.logger) + verify(fixture.fatalLogger) .log( SentryLevel.WARNING, "The Android manifest option 'io.sentry.metrics.enabled' is no longer supported. " + @@ -2090,11 +2081,7 @@ class ManifestMetadataReaderTest { @Test fun `applyMetadata warns when legacy metrics enabled metadata is false`() { - val bundle = - bundleOf( - ManifestMetadataReader.DEBUG to true, - ManifestMetadataReader.ENABLE_METRICS to false, - ) + val bundle = bundleOf(ManifestMetadataReader.ENABLE_METRICS to false) val context = fixture.getContext(metaData = bundle) val client = createSentryClientMock() @@ -2103,7 +2090,7 @@ class ManifestMetadataReaderTest { val scopes = createTestScopes(fixture.options).also { it.bindClient(client) } scopes.metrics().count("metric name") - verify(fixture.logger) + verify(fixture.fatalLogger) .log( SentryLevel.WARNING, "The Android manifest option 'io.sentry.metrics.enabled' no longer disables manual " + diff --git a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryAutoConfiguration.java b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryAutoConfiguration.java index 41726cf60cc..fe22237d2a2 100644 --- a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryAutoConfiguration.java +++ b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryAutoConfiguration.java @@ -199,7 +199,7 @@ private void warnForLegacyLogsConfiguration( Boolean.TRUE.equals(environment.getProperty("sentry.logs.enabled", Boolean.class)); if (enableLogs) { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.logs.enabled' property is no longer supported. Manual " @@ -207,7 +207,7 @@ private void warnForLegacyLogsConfiguration( + "integrations now require their own opt-ins."); } else { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.logs.enabled' property no longer disables manual Sentry.logger() " @@ -224,14 +224,14 @@ private void warnForLegacyMetricsConfiguration( Boolean.TRUE.equals(environment.getProperty("sentry.metrics.enabled", Boolean.class)); if (enableMetrics) { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.metrics.enabled' property is no longer supported. Manual " + "Sentry.metrics() calls no longer require it."); } else { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.metrics.enabled' property no longer disables manual " diff --git a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt index 5aabbdef929..00ee58a5c20 100644 --- a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt @@ -201,9 +201,8 @@ class SentryAutoConfigurationTest { fun `legacy logs property emits no warning when absent`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger, never()).log(eq(SentryLevel.WARNING), any()) } } @@ -211,9 +210,9 @@ class SentryAutoConfigurationTest { fun `legacy logs property true emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.logs.enabled=true") + .withPropertyValues("sentry.logs.enabled=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -231,9 +230,9 @@ class SentryAutoConfigurationTest { fun `legacy logs property false emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.logs.enabled=false") + .withPropertyValues("sentry.logs.enabled=false") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -251,9 +250,8 @@ class SentryAutoConfigurationTest { fun `legacy metrics property emits no warning when absent`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger, never()).log(eq(SentryLevel.WARNING), any()) } } @@ -261,9 +259,9 @@ class SentryAutoConfigurationTest { fun `legacy metrics property true emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.metrics.enabled=true") + .withPropertyValues("sentry.metrics.enabled=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -279,9 +277,9 @@ class SentryAutoConfigurationTest { fun `legacy metrics property false emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.metrics.enabled=false") + .withPropertyValues("sentry.metrics.enabled=false") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -1384,10 +1382,10 @@ class SentryAutoConfigurationTest { } @Configuration(proxyBeanMethods = false) - open class LoggerConfiguration { + open class FatalLoggerConfiguration { @Bean - open fun loggerConfiguration(logger: ILogger) = - Sentry.OptionsConfiguration { it.setLogger(logger) } + open fun fatalLoggerConfiguration(logger: ILogger) = + Sentry.OptionsConfiguration { it.setFatalLogger(logger) } } @Configuration(proxyBeanMethods = false) diff --git a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java index b215e05c7a3..b355fcbdf13 100644 --- a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java +++ b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java @@ -201,7 +201,7 @@ private void warnForLegacyLogsConfiguration( Boolean.TRUE.equals(environment.getProperty("sentry.logs.enabled", Boolean.class)); if (enableLogs) { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.logs.enabled' property is no longer supported. Manual " @@ -209,7 +209,7 @@ private void warnForLegacyLogsConfiguration( + "integrations now require their own opt-ins."); } else { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.logs.enabled' property no longer disables manual Sentry.logger() " @@ -226,14 +226,14 @@ private void warnForLegacyMetricsConfiguration( Boolean.TRUE.equals(environment.getProperty("sentry.metrics.enabled", Boolean.class)); if (enableMetrics) { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.metrics.enabled' property is no longer supported. Manual " + "Sentry.metrics() calls no longer require it."); } else { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.metrics.enabled' property no longer disables manual " diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt index df994459403..1d8b8817bd3 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt @@ -204,9 +204,8 @@ class SentryAutoConfigurationTest { fun `legacy logs property emits no warning when absent`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger, never()).log(eq(SentryLevel.WARNING), any()) } } @@ -214,9 +213,9 @@ class SentryAutoConfigurationTest { fun `legacy logs property true emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.logs.enabled=true") + .withPropertyValues("sentry.logs.enabled=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -234,9 +233,9 @@ class SentryAutoConfigurationTest { fun `legacy logs property false emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.logs.enabled=false") + .withPropertyValues("sentry.logs.enabled=false") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -254,9 +253,8 @@ class SentryAutoConfigurationTest { fun `legacy metrics property emits no warning when absent`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger, never()).log(eq(SentryLevel.WARNING), any()) } } @@ -264,9 +262,9 @@ class SentryAutoConfigurationTest { fun `legacy metrics property true emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.metrics.enabled=true") + .withPropertyValues("sentry.metrics.enabled=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -282,9 +280,9 @@ class SentryAutoConfigurationTest { fun `legacy metrics property false emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.metrics.enabled=false") + .withPropertyValues("sentry.metrics.enabled=false") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -1376,10 +1374,10 @@ class SentryAutoConfigurationTest { } @Configuration(proxyBeanMethods = false) - open class LoggerConfiguration { + open class FatalLoggerConfiguration { @Bean - open fun loggerConfiguration(logger: ILogger) = - Sentry.OptionsConfiguration { it.setLogger(logger) } + open fun fatalLoggerConfiguration(logger: ILogger) = + Sentry.OptionsConfiguration { it.setFatalLogger(logger) } } @Configuration(proxyBeanMethods = false) diff --git a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java index 37872b02fe6..0954a498e3e 100644 --- a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java +++ b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java @@ -196,7 +196,7 @@ private void warnForLegacyLogsConfiguration( Boolean.TRUE.equals(environment.getProperty("sentry.logs.enabled", Boolean.class)); if (enableLogs) { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.logs.enabled' property is no longer supported. Manual " @@ -204,7 +204,7 @@ private void warnForLegacyLogsConfiguration( + "integrations now require their own opt-ins."); } else { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.logs.enabled' property no longer disables manual Sentry.logger() " @@ -221,14 +221,14 @@ private void warnForLegacyMetricsConfiguration( Boolean.TRUE.equals(environment.getProperty("sentry.metrics.enabled", Boolean.class)); if (enableMetrics) { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.metrics.enabled' property is no longer supported. Manual " + "Sentry.metrics() calls no longer require it."); } else { options - .getLogger() + .getFatalLogger() .log( SentryLevel.WARNING, "The 'sentry.metrics.enabled' property no longer disables manual " diff --git a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt index 2315a616d28..39185e581fc 100644 --- a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt @@ -202,9 +202,8 @@ class SentryAutoConfigurationTest { fun `legacy logs property emits no warning when absent`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger, never()).log(eq(SentryLevel.WARNING), any()) } } @@ -212,9 +211,9 @@ class SentryAutoConfigurationTest { fun `legacy logs property true emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.logs.enabled=true") + .withPropertyValues("sentry.logs.enabled=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -232,9 +231,9 @@ class SentryAutoConfigurationTest { fun `legacy logs property false emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.logs.enabled=false") + .withPropertyValues("sentry.logs.enabled=false") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -252,9 +251,8 @@ class SentryAutoConfigurationTest { fun `legacy metrics property emits no warning when absent`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger, never()).log(eq(SentryLevel.WARNING), any()) } } @@ -262,9 +260,9 @@ class SentryAutoConfigurationTest { fun `legacy metrics property true emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.metrics.enabled=true") + .withPropertyValues("sentry.metrics.enabled=true") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -280,9 +278,9 @@ class SentryAutoConfigurationTest { fun `legacy metrics property false emits migration warning`() { val logger = mock() dsnEnabledRunner - .withPropertyValues("sentry.debug=true", "sentry.metrics.enabled=false") + .withPropertyValues("sentry.metrics.enabled=false") .withBean(ILogger::class.java, { logger }) - .withUserConfiguration(LoggerConfiguration::class.java) + .withUserConfiguration(FatalLoggerConfiguration::class.java) .run { verify(logger) .log( @@ -1309,10 +1307,10 @@ class SentryAutoConfigurationTest { } @Configuration(proxyBeanMethods = false) - open class LoggerConfiguration { + open class FatalLoggerConfiguration { @Bean - open fun loggerConfiguration(logger: ILogger) = - Sentry.OptionsConfiguration { it.setLogger(logger) } + open fun fatalLoggerConfiguration(logger: ILogger) = + Sentry.OptionsConfiguration { it.setFatalLogger(logger) } } @Configuration(proxyBeanMethods = false) diff --git a/sentry/src/main/java/io/sentry/Sentry.java b/sentry/src/main/java/io/sentry/Sentry.java index 266aa39e793..b429465ea9e 100644 --- a/sentry/src/main/java/io/sentry/Sentry.java +++ b/sentry/src/main/java/io/sentry/Sentry.java @@ -306,6 +306,7 @@ private static void init(final @NotNull SentryOptions options, final boolean glo + options.getClass().getName()); } + initFatalLogger(options); if (!preInitConfigurations(options)) { return; } @@ -317,7 +318,6 @@ private static void init(final @NotNull SentryOptions options, final boolean glo .getLogger() .log(SentryLevel.INFO, "GlobalHubMode: '%s'", String.valueOf(globalHubModeToUse)); Sentry.globalHubMode = globalHubModeToUse; - initFatalLogger(options); final boolean shouldInit = InitUtil.shouldInit(globalScope.getOptions(), options, isEnabled()); if (shouldInit) { diff --git a/sentry/src/main/java/io/sentry/SentryOptions.java b/sentry/src/main/java/io/sentry/SentryOptions.java index 33948ead53e..f33fd78f98c 100644 --- a/sentry/src/main/java/io/sentry/SentryOptions.java +++ b/sentry/src/main/java/io/sentry/SentryOptions.java @@ -3735,13 +3735,13 @@ public void merge(final @NotNull ExternalOptions options) { if (options.isEnableLogs() != null) { if (options.isEnableLogs()) { - logger.log( + fatalLogger.log( SentryLevel.WARNING, "The 'logs.enabled' option is no longer supported. Manual Sentry.logger() calls no " + "longer require it, and automatic logging integrations now require their own " + "opt-ins."); } else { - logger.log( + fatalLogger.log( SentryLevel.WARNING, "The 'logs.enabled' option no longer disables manual Sentry.logger() calls. Automatic " + "logging integrations remain disabled unless enabled through their own opt-ins."); @@ -3750,12 +3750,12 @@ public void merge(final @NotNull ExternalOptions options) { if (options.isEnableMetrics() != null) { if (options.isEnableMetrics()) { - logger.log( + fatalLogger.log( SentryLevel.WARNING, "The 'metrics.enabled' option is no longer supported. Manual Sentry.metrics() calls no " + "longer require it."); } else { - logger.log( + fatalLogger.log( SentryLevel.WARNING, "The 'metrics.enabled' option no longer disables manual Sentry.metrics() calls."); } diff --git a/sentry/src/test/java/io/sentry/SentryOptionsTest.kt b/sentry/src/test/java/io/sentry/SentryOptionsTest.kt index 398a1de11b0..2d94c4fad1f 100644 --- a/sentry/src/test/java/io/sentry/SentryOptionsTest.kt +++ b/sentry/src/test/java/io/sentry/SentryOptionsTest.kt @@ -501,30 +501,22 @@ class SentryOptionsTest { @Test fun `merging options does not warn when legacy logs configuration is absent`() { - val logger = mock() - val options = - SentryOptions().also { - it.isDebug = true - it.setLogger(logger) - } + val fatalLogger = mock() + val options = SentryOptions().also { it.setFatalLogger(fatalLogger) } options.merge(ExternalOptions()) - verify(logger, never()).log(eq(SentryLevel.WARNING), any()) + verify(fatalLogger, never()).log(eq(SentryLevel.WARNING), any()) } @Test - fun `merging options warns when legacy logs configuration is true`() { - val logger = mock() - val options = - SentryOptions().also { - it.isDebug = true - it.setLogger(logger) - } + fun `merging options warns through fatal logger when legacy logs configuration is true`() { + val fatalLogger = mock() + val options = SentryOptions().also { it.setFatalLogger(fatalLogger) } options.merge(ExternalOptions().apply { isEnableLogs = true }) - verify(logger) + verify(fatalLogger) .log( SentryLevel.WARNING, "The 'logs.enabled' option is no longer supported. Manual Sentry.logger() calls no " + @@ -535,17 +527,13 @@ class SentryOptionsTest { } @Test - fun `merging options warns when legacy logs configuration is false`() { - val logger = mock() - val options = - SentryOptions().also { - it.isDebug = true - it.setLogger(logger) - } + fun `merging options warns through fatal logger when legacy logs configuration is false`() { + val fatalLogger = mock() + val options = SentryOptions().also { it.setFatalLogger(fatalLogger) } options.merge(ExternalOptions().apply { isEnableLogs = false }) - verify(logger) + verify(fatalLogger) .log( SentryLevel.WARNING, "The 'logs.enabled' option no longer disables manual Sentry.logger() calls. Automatic " + @@ -567,30 +555,22 @@ class SentryOptionsTest { @Test fun `merging options does not warn when legacy metrics configuration is absent`() { - val logger = mock() - val options = - SentryOptions().also { - it.isDebug = true - it.setLogger(logger) - } + val fatalLogger = mock() + val options = SentryOptions().also { it.setFatalLogger(fatalLogger) } options.merge(ExternalOptions()) - verify(logger, never()).log(eq(SentryLevel.WARNING), any()) + verify(fatalLogger, never()).log(eq(SentryLevel.WARNING), any()) } @Test - fun `merging options warns when legacy metrics configuration is true`() { - val logger = mock() - val options = - SentryOptions().also { - it.isDebug = true - it.setLogger(logger) - } + fun `merging options warns through fatal logger when legacy metrics configuration is true`() { + val fatalLogger = mock() + val options = SentryOptions().also { it.setFatalLogger(fatalLogger) } options.merge(ExternalOptions().apply { isEnableMetrics = true }) - verify(logger) + verify(fatalLogger) .log( SentryLevel.WARNING, "The 'metrics.enabled' option is no longer supported. Manual Sentry.metrics() calls no " + @@ -601,17 +581,13 @@ class SentryOptionsTest { } @Test - fun `merging options warns when legacy metrics configuration is false`() { - val logger = mock() - val options = - SentryOptions().also { - it.isDebug = true - it.setLogger(logger) - } + fun `merging options warns through fatal logger when legacy metrics configuration is false`() { + val fatalLogger = mock() + val options = SentryOptions().also { it.setFatalLogger(fatalLogger) } options.merge(ExternalOptions().apply { isEnableMetrics = false }) - verify(logger) + verify(fatalLogger) .log( SentryLevel.WARNING, "The 'metrics.enabled' option no longer disables manual Sentry.metrics() calls.", diff --git a/sentry/src/test/java/io/sentry/SentryTest.kt b/sentry/src/test/java/io/sentry/SentryTest.kt index 98cda8e9d82..680d846ecc9 100644 --- a/sentry/src/test/java/io/sentry/SentryTest.kt +++ b/sentry/src/test/java/io/sentry/SentryTest.kt @@ -24,9 +24,11 @@ import io.sentry.test.injectForField import io.sentry.util.PlatformTestManipulator import io.sentry.util.thread.IThreadChecker import io.sentry.util.thread.ThreadChecker +import java.io.ByteArrayOutputStream import java.io.Closeable import java.io.File import java.io.FileReader +import java.io.PrintStream import java.nio.file.Files import java.util.Properties import java.util.concurrent.CompletableFuture @@ -299,10 +301,38 @@ class SentryTest { initForTest { it.isEnableExternalConfiguration = true } assertTrue(ScopesAdapter.getInstance().isEnabled) } finally { + System.clearProperty("sentry.properties.file") temporaryFolder.delete() } } + @Test + fun `external legacy configuration warning is visible when debug is disabled`() { + val file = tmpDir.newFile("sentry.properties") + file.writeText("dsn=$dsn\nlogs.enabled=true") + System.setProperty("sentry.properties.file", file.absolutePath) + val originalOut = System.out + val output = ByteArrayOutputStream() + System.setOut(PrintStream(output)) + + try { + initForTest { it.isEnableExternalConfiguration = true } + } finally { + System.setOut(originalOut) + System.clearProperty("sentry.properties.file") + } + + assertTrue( + output + .toString() + .contains( + "WARNING: The 'logs.enabled' option is no longer supported. Manual Sentry.logger() " + + "calls no longer require it, and automatic logging integrations now require their " + + "own opt-ins." + ) + ) + } + @Test fun `initializes Sentry with enabled=false, thus disabling Sentry even if dsn is set`() { initForTest { From 8eeaffb01e46cf69547da80a3fe7d4480854e775 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Fri, 14 Aug 2026 13:57:39 +0200 Subject: [PATCH 02/10] ref(logging): Rename Logs opt-ins Use state-oriented names for the new Logback, Log4j2, JUL, Timber, Logcat, and Spring Boot Logs controls. Expose get...Enabled accessors so Java-defined options map to natural Kotlin properties before these APIs are released. Co-Authored-By: Claude --- .cursor/rules/options.mdc | 18 ++++---- .../api/sentry-android-core.api | 8 ++-- .../core/AndroidOptionsInitializer.java | 2 +- .../android/core/ManifestMetadataReader.java | 8 ++-- .../android/core/SentryAndroidOptions.java | 20 ++++----- .../android/core/SentryLogcatAdapter.java | 2 +- .../core/AndroidOptionsInitializerTest.kt | 6 +-- .../core/ManifestMetadataReaderTest.kt | 24 +++++----- .../android/core/SentryAndroidOptionsTest.kt | 12 ++--- .../sentry/android/core/SentryAndroidTest.kt | 4 +- .../android/core/SentryLogcatAdapterTest.kt | 12 ++--- .../api/sentry-android-timber.api | 2 +- .../android/timber/SentryTimberIntegration.kt | 20 ++++----- .../sentry/android/timber/SentryTimberTree.kt | 8 ++-- .../timber/SentryTimberIntegrationTest.kt | 18 ++++---- .../android/timber/SentryTimberTreeTest.kt | 8 ++-- sentry-jul/api/sentry-jul.api | 4 +- .../java/io/sentry/jul/SentryHandler.java | 14 +++--- .../kotlin/io/sentry/jul/SentryHandlerTest.kt | 22 ++++----- .../src/test/resources/logging.properties | 2 +- .../java/io/sentry/log4j2/SentryAppender.java | 12 ++--- .../io/sentry/log4j2/SentryAppenderTest.kt | 10 ++--- sentry-logback/api/sentry-logback.api | 4 +- .../io/sentry/logback/SentryAppender.java | 12 ++--- .../io/sentry/logback/SentryAppenderTest.kt | 45 ++++++++++--------- .../src/main/resources/logging.properties | 2 +- .../src/main/resources/log4j2.xml | 2 +- .../src/main/resources/logback.xml | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- .../api/sentry-spring-boot-4.api | 4 +- .../boot4/SentryLogbackInitializer.java | 2 +- .../sentry/spring/boot4/SentryProperties.java | 10 ++--- .../boot4/SentryAutoConfigurationTest.kt | 8 ++-- ...tryLogbackAppenderAutoConfigurationTest.kt | 6 +-- .../api/sentry-spring-boot-jakarta.api | 4 +- .../jakarta/SentryLogbackInitializer.java | 2 +- .../spring/boot/jakarta/SentryProperties.java | 10 ++--- .../jakarta/SentryAutoConfigurationTest.kt | 8 ++-- ...tryLogbackAppenderAutoConfigurationTest.kt | 6 +-- sentry-spring-boot/api/sentry-spring-boot.api | 4 +- .../spring/boot/SentryLogbackInitializer.java | 2 +- .../sentry/spring/boot/SentryProperties.java | 10 ++--- .../boot/SentryAutoConfigurationTest.kt | 8 ++-- ...tryLogbackAppenderAutoConfigurationTest.kt | 6 +-- 56 files changed, 210 insertions(+), 209 deletions(-) diff --git a/.cursor/rules/options.mdc b/.cursor/rules/options.mdc index 24e1dadc586..3983ff5aa69 100644 --- a/.cursor/rules/options.mdc +++ b/.cursor/rules/options.mdc @@ -76,7 +76,7 @@ Allows setting options via `AndroidManifest.xml` `` tags. - Add a `static final String` constant for the key - Read it in `applyMetadata()` using `readBool(metadata, logger, CONSTANT, defaultValue)` - Apply automatic-source options directly, for example - `options.setEnableLogcatLogs(...)` for `io.sentry.logcat.logs.enabled` + `options.setLogcatLogsEnabled(...)` for `io.sentry.logcat.logs.enabled` - Do not add or restore `io.sentry.logs.enabled` or `io.sentry.metrics.enabled`; those aggregate keys are obsolete and are read only to emit migration warnings. @@ -89,8 +89,8 @@ Allows setting options via `AndroidManifest.xml` `` tags. `SentryProperties` extends `SentryOptions`, so bindable namespaced behavior options are available through the `SentryOptions` class hierarchy. Spring-owned integration controls belong to a Spring -namespace instead. For example, `SentryProperties.Logging.enableLogs` binds to -`sentry.logging.enable-logs` and controls Logs forwarding from the auto-configured Logback +namespace instead. For example, `SentryProperties.Logging.logsEnabled` binds to +`sentry.logging.logs-enabled` and controls Logs forwarding from the auto-configured Logback appender. `sentry.logging.enabled` separately controls whether that appender is installed. Do not add or restore `sentry.logs.enabled` or `sentry.metrics.enabled`. Spring detects those legacy @@ -110,12 +110,12 @@ They capture whenever their scopes are enabled, then apply signal behavior such Automatic integrations must check their source-local opt-in without affecting their existing event or breadcrumb paths. Current Logs controls are: -- Logback: appender `enableLogs` -- Log4j2: appender `enableLogs` -- JUL: handler `enableLogs` -- Spring Boot Logback: `sentry.logging.enable-logs` -- Timber: `enableTimberLogs` / `io.sentry.timber.logs.enabled` -- Logcat: `enableLogcatLogs` / `io.sentry.logcat.logs.enabled` +- Logback: appender `logsEnabled` +- Log4j2: appender `logsEnabled` +- JUL: handler `logsEnabled` +- Spring Boot Logback: `sentry.logging.logs-enabled` +- Timber: `timberLogsEnabled` / `io.sentry.timber.logs.enabled` +- Logcat: `logcatLogsEnabled` / `io.sentry.logcat.logs.enabled` All source-local options default to `false` and gate only Sentry Logs forwarding. diff --git a/sentry-android-core/api/sentry-android-core.api b/sentry-android-core/api/sentry-android-core.api index 16b9caabc48..60c9ed2b3e3 100644 --- a/sentry-android-core/api/sentry-android-core.api +++ b/sentry-android-core/api/sentry-android-core.api @@ -408,11 +408,13 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun getBeforeViewHierarchyCaptureCallback ()Lio/sentry/android/core/SentryAndroidOptions$BeforeCaptureCallback; public fun getDebugImagesLoader ()Lio/sentry/android/core/IDebugImagesLoader; public fun getFrameMetricsCollector ()Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector; + public fun getLogcatLogsEnabled ()Z public fun getNativeSdkName ()Ljava/lang/String; public fun getNdkAppHangTimeoutIntervalMillis ()J public fun getNdkHandlerStrategy ()I public fun getScreenshot ()Lio/sentry/android/core/SentryScreenshotOptions; public fun getStartupCrashDurationThresholdMillis ()J + public fun getTimberLogsEnabled ()Z public fun isAnrEnabled ()Z public fun isAnrProfilingEnabled ()Z public fun isAnrReportInDebug ()Z @@ -430,7 +432,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun isEnableAutoActivityLifecycleTracing ()Z public fun isEnableAutoTraceIdGeneration ()Z public fun isEnableFramesTracking ()Z - public fun isEnableLogcatLogs ()Z public fun isEnableNdk ()Z public fun isEnableNdkAppHangTracking ()Z public fun isEnableNetworkEventBreadcrumbs ()Z @@ -440,7 +441,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun isEnableStandaloneAppStartTracing ()Z public fun isEnableSystemEventBreadcrumbs ()Z public fun isEnableSystemEventBreadcrumbsExtras ()Z - public fun isEnableTimberLogs ()Z public fun isReportHistoricalAnrs ()Z public fun isReportHistoricalTombstones ()Z public fun isTombstoneEnabled ()Z @@ -465,7 +465,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun setEnableAutoActivityLifecycleTracing (Z)V public fun setEnableAutoTraceIdGeneration (Z)V public fun setEnableFramesTracking (Z)V - public fun setEnableLogcatLogs (Z)V public fun setEnableNdk (Z)V public fun setEnableNdkAppHangTracking (Z)V public fun setEnableNetworkEventBreadcrumbs (Z)V @@ -475,13 +474,14 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun setEnableStandaloneAppStartTracing (Z)V public fun setEnableSystemEventBreadcrumbs (Z)V public fun setEnableSystemEventBreadcrumbsExtras (Z)V - public fun setEnableTimberLogs (Z)V public fun setFrameMetricsCollector (Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V + public fun setLogcatLogsEnabled (Z)V public fun setNativeHandlerStrategy (Lio/sentry/android/core/NdkHandlerStrategy;)V public fun setNativeSdkName (Ljava/lang/String;)V public fun setNdkAppHangTimeoutIntervalMillis (J)V public fun setReportHistoricalAnrs (Z)V public fun setReportHistoricalTombstones (Z)V + public fun setTimberLogsEnabled (Z)V public fun setTombstoneEnabled (Z)V } diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java b/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java index cd47f96d87b..07d388157b9 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java @@ -473,7 +473,7 @@ static void installDefaultIntegrations( } if (isTimberAvailable) { - options.addIntegration(new SentryTimberIntegration(options::isEnableTimberLogs)); + options.addIntegration(new SentryTimberIntegration(options::getTimberLogsEnabled)); } options.addIntegration(new AppComponentsBreadcrumbsIntegration(context)); options.addIntegration(new SystemEventsBreadcrumbsIntegration(context)); diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java index d94d2aa72ab..3e30a441c50 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java @@ -746,11 +746,11 @@ static void applyMetadata( } } - options.setEnableTimberLogs( - readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.isEnableTimberLogs())); + options.setTimberLogsEnabled( + readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogsEnabled())); - options.setEnableLogcatLogs( - readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.isEnableLogcatLogs())); + options.setLogcatLogsEnabled( + readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogsEnabled())); final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions(); feedbackOptions.setNameRequired( diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java b/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java index ade7a5fc953..44e6def83e9 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java @@ -72,10 +72,10 @@ public final class SentryAndroidOptions extends SentryOptions { private boolean enableNetworkEventBreadcrumbs = true; /** Enable or disable automatic Sentry Logs capture from Timber. Default is disabled. */ - private boolean enableTimberLogs = false; + private boolean timberLogsEnabled = false; /** Enable or disable automatic Sentry Logs capture from Logcat. Default is disabled. */ - private boolean enableLogcatLogs = false; + private boolean logcatLogsEnabled = false; /** * Enables the Auto instrumentation for Activity lifecycle tracing. @@ -463,20 +463,20 @@ public void setEnableNetworkEventBreadcrumbs(boolean enableNetworkEventBreadcrum this.enableNetworkEventBreadcrumbs = enableNetworkEventBreadcrumbs; } - public boolean isEnableTimberLogs() { - return enableTimberLogs; + public boolean getTimberLogsEnabled() { + return timberLogsEnabled; } - public void setEnableTimberLogs(boolean enableTimberLogs) { - this.enableTimberLogs = enableTimberLogs; + public void setTimberLogsEnabled(boolean timberLogsEnabled) { + this.timberLogsEnabled = timberLogsEnabled; } - public boolean isEnableLogcatLogs() { - return enableLogcatLogs; + public boolean getLogcatLogsEnabled() { + return logcatLogsEnabled; } - public void setEnableLogcatLogs(boolean enableLogcatLogs) { - this.enableLogcatLogs = enableLogcatLogs; + public void setLogcatLogsEnabled(boolean logcatLogsEnabled) { + this.logcatLogsEnabled = logcatLogsEnabled; } /** diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java b/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java index 998ce58b3db..f0dac8629ad 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java @@ -55,7 +55,7 @@ private static void addAsLog( final @NotNull ScopesAdapter scopes = ScopesAdapter.getInstance(); final @NotNull SentryOptions options = scopes.getOptions(); if (!(options instanceof SentryAndroidOptions) - || !((SentryAndroidOptions) options).isEnableLogcatLogs()) { + || !((SentryAndroidOptions) options).getLogcatLogsEnabled()) { return; } final @Nullable String trMessage = tr != null ? tr.getMessage() : null; diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt index 894ea9dfa4b..5f3bcaa8b5e 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt @@ -704,18 +704,18 @@ class AndroidOptionsInitializerTest { val actual = fixture.sentryOptions.integrations.firstOrNull { it is SentryTimberIntegration } as SentryTimberIntegration - assertFalse(actual.enableLogs) + assertFalse(actual.logsEnabled) } @Test fun `SentryTimberIntegration receives Timber logs option`() { - fixture.sentryOptions.isEnableTimberLogs = true + fixture.sentryOptions.timberLogsEnabled = true fixture.initSutWithClassLoader(isTimberAvailable = true) val actual = fixture.sentryOptions.integrations.firstOrNull { it is SentryTimberIntegration } as SentryTimberIntegration - assertTrue(actual.enableLogs) + assertTrue(actual.logsEnabled) } @Test diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt index df361b0de1d..b49f767a927 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt @@ -1975,14 +1975,14 @@ class ManifestMetadataReaderTest { "integrations now require their own opt-ins.", *emptyArray(), ) - assertThat(fixture.options.isEnableTimberLogs).isFalse() - assertThat(fixture.options.isEnableLogcatLogs).isFalse() + assertThat(fixture.options.timberLogsEnabled).isFalse() + assertThat(fixture.options.logcatLogsEnabled).isFalse() } @Test fun `applyMetadata warns when legacy logs enabled metadata is false`() { - fixture.options.isEnableTimberLogs = true - fixture.options.isEnableLogcatLogs = true + fixture.options.timberLogsEnabled = true + fixture.options.logcatLogsEnabled = true val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGS to false) val context = fixture.getContext(metaData = bundle) @@ -1996,8 +1996,8 @@ class ManifestMetadataReaderTest { "enabled through their own opt-ins.", *emptyArray(), ) - assertThat(fixture.options.isEnableTimberLogs).isTrue() - assertThat(fixture.options.isEnableLogcatLogs).isTrue() + assertThat(fixture.options.timberLogsEnabled).isTrue() + assertThat(fixture.options.logcatLogsEnabled).isTrue() } @Test @@ -2006,7 +2006,7 @@ class ManifestMetadataReaderTest { ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertFalse(fixture.options.isEnableTimberLogs) + assertFalse(fixture.options.timberLogsEnabled) } @Test @@ -2016,7 +2016,7 @@ class ManifestMetadataReaderTest { ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertTrue(fixture.options.isEnableTimberLogs) + assertTrue(fixture.options.timberLogsEnabled) } @Test @@ -2025,7 +2025,7 @@ class ManifestMetadataReaderTest { ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertThat(fixture.options.isEnableLogcatLogs).isFalse() + assertThat(fixture.options.logcatLogsEnabled).isFalse() } @Test @@ -2035,18 +2035,18 @@ class ManifestMetadataReaderTest { ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertThat(fixture.options.isEnableLogcatLogs).isTrue() + assertThat(fixture.options.logcatLogsEnabled).isTrue() } @Test fun `applyMetadata reads Logcat logs disabled to options`() { - fixture.options.isEnableLogcatLogs = true + fixture.options.logcatLogsEnabled = true val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to false) val context = fixture.getContext(metaData = bundle) ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertThat(fixture.options.isEnableLogcatLogs).isFalse() + assertThat(fixture.options.logcatLogsEnabled).isFalse() } @Test diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt index 4d1fbad0dd7..8fa68e77e67 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt @@ -98,28 +98,28 @@ class SentryAndroidOptionsTest { fun `Timber logs are disabled by default`() { val sentryOptions = SentryAndroidOptions() - assertFalse(sentryOptions.isEnableTimberLogs) + assertFalse(sentryOptions.timberLogsEnabled) } @Test fun `Timber logs can be enabled`() { val sentryOptions = SentryAndroidOptions() - sentryOptions.isEnableTimberLogs = true + sentryOptions.timberLogsEnabled = true - assertTrue(sentryOptions.isEnableTimberLogs) + assertTrue(sentryOptions.timberLogsEnabled) } @Test fun `Logcat logs are disabled by default`() { - assertThat(SentryAndroidOptions().isEnableLogcatLogs).isFalse() + assertThat(SentryAndroidOptions().logcatLogsEnabled).isFalse() } @Test fun `Logcat logs can be enabled`() { val sentryOptions = SentryAndroidOptions() - sentryOptions.isEnableLogcatLogs = true + sentryOptions.logcatLogsEnabled = true - assertThat(sentryOptions.isEnableLogcatLogs).isTrue() + assertThat(sentryOptions.logcatLogsEnabled).isTrue() } @Test diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt index cacdaf08348..00353a806f1 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt @@ -244,7 +244,7 @@ class SentryAndroidTest { fun `auto-installed Timber integration uses Logs option set in configuration callback`() { val logs = mutableListOf() fixture.initSut { options -> - options.isEnableTimberLogs = true + options.timberLogsEnabled = true options.logs.beforeSend = SentryOptions.Logs.BeforeSendLogCallback { log -> logs.add(log) @@ -268,7 +268,7 @@ class SentryAndroidTest { val logs = mutableListOf() initForTest(mockContext) { options -> - options.isEnableTimberLogs = false + options.timberLogsEnabled = false options.logs.beforeSend = SentryOptions.Logs.BeforeSendLogCallback { log -> logs.add(log) diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt index 582f475f68d..0e4717c458c 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt @@ -28,7 +28,7 @@ class SentryLogcatAdapterTest { val logs = mutableListOf() fun initSut( - enableLogcatLogs: Boolean? = true, + logcatLogsEnabled: Boolean? = true, metadata: Bundle = Bundle(), options: Sentry.OptionsConfiguration? = null, ) { @@ -39,8 +39,8 @@ class SentryLogcatAdapterTest { breadcrumbs.add(breadcrumb) breadcrumb } - if (enableLogcatLogs != null) { - it.isEnableLogcatLogs = enableLogcatLogs + if (logcatLogsEnabled != null) { + it.logcatLogsEnabled = logcatLogsEnabled } it.logs.beforeSend = SentryOptions.Logs.BeforeSendLogCallback { logEvent -> @@ -66,7 +66,7 @@ class SentryLogcatAdapterTest { @Test fun `Logcat logs are disabled by default while breadcrumbs and Android Log remain enabled`() { - fixture.initSut(enableLogcatLogs = null) + fixture.initSut(logcatLogsEnabled = null) SentryLogcatAdapter.d(tag, commonMsg) @@ -77,7 +77,7 @@ class SentryLogcatAdapterTest { @Test fun `Logcat logs can be enabled through Android options`() { - fixture.initSut(enableLogcatLogs = true) + fixture.initSut(logcatLogsEnabled = true) SentryLogcatAdapter.d(tag, commonMsg) @@ -87,7 +87,7 @@ class SentryLogcatAdapterTest { @Test fun `Logcat logs can be enabled through manifest metadata`() { val metadata = Bundle().apply { putBoolean(ManifestMetadataReader.ENABLE_LOGCAT_LOGS, true) } - fixture.initSut(enableLogcatLogs = null, metadata = metadata) + fixture.initSut(logcatLogsEnabled = null, metadata = metadata) SentryLogcatAdapter.d(tag, commonMsg) diff --git a/sentry-android-timber/api/sentry-android-timber.api b/sentry-android-timber/api/sentry-android-timber.api index 275460a0346..32a8407e41b 100644 --- a/sentry-android-timber/api/sentry-android-timber.api +++ b/sentry-android-timber/api/sentry-android-timber.api @@ -15,7 +15,7 @@ public final class io/sentry/android/timber/SentryTimberIntegration : io/sentry/ public fun (Lio/sentry/util/LazyEvaluator$Evaluator;)V public fun (Z)V public fun close ()V - public final fun getEnableLogs ()Z + public final fun getLogsEnabled ()Z public final fun getMinBreadcrumbLevel ()Lio/sentry/SentryLevel; public final fun getMinEventLevel ()Lio/sentry/SentryLevel; public final fun getMinLogsLevel ()Lio/sentry/SentryLogLevel; diff --git a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt index ba8956696d0..93d2104489f 100644 --- a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt +++ b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt @@ -19,26 +19,26 @@ public class SentryTimberIntegration( public val minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, public val minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, ) : Integration, Closeable { - public val enableLogs: Boolean - get() = enableLogsProvider.evaluate() + public val logsEnabled: Boolean + get() = logsEnabledProvider.evaluate() - private var enableLogsProvider: Evaluator = Evaluator { false } + private var logsEnabledProvider: Evaluator = Evaluator { false } - public constructor(enableLogs: Boolean) : this() { - enableLogsProvider = Evaluator { enableLogs } + public constructor(logsEnabled: Boolean) : this() { + logsEnabledProvider = Evaluator { logsEnabled } } public constructor( minEventLevel: SentryLevel, minBreadcrumbLevel: SentryLevel, minLogsLevel: SentryLogLevel, - enableLogs: Boolean, + logsEnabled: Boolean, ) : this(minEventLevel, minBreadcrumbLevel, minLogsLevel) { - enableLogsProvider = Evaluator { enableLogs } + logsEnabledProvider = Evaluator { logsEnabled } } - public constructor(enableLogsProvider: Evaluator) : this() { - this.enableLogsProvider = enableLogsProvider + public constructor(logsEnabledProvider: Evaluator) : this() { + this.logsEnabledProvider = logsEnabledProvider } private lateinit var tree: SentryTimberTree @@ -60,7 +60,7 @@ public class SentryTimberIntegration( minEventLevel, minBreadcrumbLevel, minLogsLevel, - enableLogsProvider.evaluate(), + logsEnabledProvider.evaluate(), ) Timber.plant(tree) diff --git a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt index f63dd7b66d0..9d3f86fa81d 100644 --- a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt +++ b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt @@ -20,16 +20,16 @@ public class SentryTimberTree( private val minBreadcrumbLevel: SentryLevel, private val minLogLevel: SentryLogLevel = SentryLogLevel.INFO, ) : Timber.Tree() { - private var enableLogs: Boolean = false + private var logsEnabled: Boolean = false public constructor( scopes: IScopes, minEventLevel: SentryLevel, minBreadcrumbLevel: SentryLevel, minLogLevel: SentryLogLevel, - enableLogs: Boolean, + logsEnabled: Boolean, ) : this(scopes, minEventLevel, minBreadcrumbLevel, minLogLevel) { - this.enableLogs = enableLogs + this.logsEnabled = logsEnabled } private val pendingTag = ThreadLocal() @@ -197,7 +197,7 @@ public class SentryTimberTree( captureEvent(level, tag, sentryMessage, throwable) addBreadcrumb(level, sentryMessage, throwable) - if (enableLogs) { + if (logsEnabled) { addLog(logLevel, message, tag, throwable, *args) } } diff --git a/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt b/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt index 6597d528f87..4fae8bc6855 100644 --- a/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt +++ b/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt @@ -39,9 +39,9 @@ class SentryTimberIntegrationTest { minEventLevel: SentryLevel = SentryLevel.ERROR, minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, - enableLogs: Boolean? = null, + logsEnabled: Boolean? = null, ): SentryTimberIntegration = - if (enableLogs == null) { + if (logsEnabled == null) { SentryTimberIntegration( minEventLevel = minEventLevel, minBreadcrumbLevel = minBreadcrumbLevel, @@ -52,7 +52,7 @@ class SentryTimberIntegrationTest { minEventLevel = minEventLevel, minBreadcrumbLevel = minBreadcrumbLevel, minLogsLevel = minLogsLevel, - enableLogs = enableLogs, + logsEnabled = logsEnabled, ) } } @@ -90,7 +90,7 @@ class SentryTimberIntegrationTest { val sut = fixture.getSut() sut.register(fixture.scopes, fixture.options) - assertFalse(sut.enableLogs) + assertFalse(sut.logsEnabled) Timber.e("message") verify(fixture.scopes).captureEvent(any()) @@ -100,10 +100,10 @@ class SentryTimberIntegrationTest { @Test fun `Manual integration captures logs when enabled`() { - val sut = fixture.getSut(enableLogs = true) + val sut = fixture.getSut(logsEnabled = true) sut.register(fixture.scopes, fixture.options) - assertTrue(sut.enableLogs) + assertTrue(sut.logsEnabled) Timber.i("message") verify(fixture.logs).log(any(), any(), any()) @@ -111,9 +111,9 @@ class SentryTimberIntegrationTest { @Test fun `Integration evaluates Logs provider when registered`() { - var enableLogs = false - val sut = SentryTimberIntegration(Evaluator { enableLogs }) - enableLogs = true + var logsEnabled = false + val sut = SentryTimberIntegration(Evaluator { logsEnabled }) + logsEnabled = true sut.register(fixture.scopes, fixture.options) Timber.i("message") diff --git a/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberTreeTest.kt b/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberTreeTest.kt index 457ab31d33c..6206bb783ba 100644 --- a/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberTreeTest.kt +++ b/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberTreeTest.kt @@ -31,15 +31,15 @@ class SentryTimberTreeTest { minEventLevel: SentryLevel = SentryLevel.ERROR, minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, - enableLogs: Boolean? = true, + logsEnabled: Boolean? = true, ): SentryTimberTree { logs = mock() scopes = mock() whenever(scopes.logger()).thenReturn(logs) - return if (enableLogs == null) { + return if (logsEnabled == null) { SentryTimberTree(scopes, minEventLevel, minBreadcrumbLevel, minLogsLevel) } else { - SentryTimberTree(scopes, minEventLevel, minBreadcrumbLevel, minLogsLevel, enableLogs) + SentryTimberTree(scopes, minEventLevel, minBreadcrumbLevel, minLogsLevel, logsEnabled) } } } @@ -303,7 +303,7 @@ class SentryTimberTreeTest { @Test fun `Tree defaults logs to disabled while capturing events and breadcrumbs`() { - val sut = fixture.getSut(enableLogs = null) + val sut = fixture.getSut(logsEnabled = null) sut.e("message") diff --git a/sentry-jul/api/sentry-jul.api b/sentry-jul/api/sentry-jul.api index 1fdf4895971..e23503666eb 100644 --- a/sentry-jul/api/sentry-jul.api +++ b/sentry-jul/api/sentry-jul.api @@ -12,13 +12,13 @@ public class io/sentry/jul/SentryHandler : java/util/logging/Handler { protected fun captureLog (Ljava/util/logging/LogRecord;)V public fun close ()V public fun flush ()V + public fun getLogsEnabled ()Z public fun getMinimumBreadcrumbLevel ()Ljava/util/logging/Level; public fun getMinimumEventLevel ()Ljava/util/logging/Level; public fun getMinimumLevel ()Ljava/util/logging/Level; - public fun isEnableLogs ()Z public fun isPrintfStyle ()Z public fun publish (Ljava/util/logging/LogRecord;)V - public fun setEnableLogs (Z)V + public fun setLogsEnabled (Z)V public fun setMinimumBreadcrumbLevel (Ljava/util/logging/Level;)V public fun setMinimumEventLevel (Ljava/util/logging/Level;)V public fun setMinimumLevel (Ljava/util/logging/Level;)V diff --git a/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java b/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java index bb1cce04445..d9dcae0f8b1 100644 --- a/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java +++ b/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java @@ -53,7 +53,7 @@ public class SentryHandler extends Handler { */ private boolean printfStyle; - private boolean enableLogs; + private boolean logsEnabled; private @NotNull Level minimumBreadcrumbLevel = Level.INFO; private @NotNull Level minimumEventLevel = Level.SEVERE; @@ -114,7 +114,7 @@ public void publish(final @NotNull LogRecord record) { return; } try { - if (enableLogs && record.getLevel().intValue() >= minimumLevel.intValue()) { + if (logsEnabled && record.getLevel().intValue() >= minimumLevel.intValue()) { captureLog(record); } if (record.getLevel().intValue() >= minimumEventLevel.intValue()) { @@ -197,7 +197,7 @@ private void retrieveProperties() { final LogManager manager = LogManager.getLogManager(); final String className = SentryHandler.class.getName(); setPrintfStyle(Boolean.parseBoolean(manager.getProperty(className + ".printfStyle"))); - setEnableLogs(Boolean.parseBoolean(manager.getProperty(className + ".enableLogs"))); + setLogsEnabled(Boolean.parseBoolean(manager.getProperty(className + ".logsEnabled"))); setLevel(parseLevelOrDefault(manager.getProperty(className + ".level"))); final String minimumBreadCrumbLevel = manager.getProperty(className + ".minimumBreadcrumbLevel"); @@ -397,12 +397,12 @@ public void setPrintfStyle(final boolean printfStyle) { this.printfStyle = printfStyle; } - public void setEnableLogs(final boolean enableLogs) { - this.enableLogs = enableLogs; + public void setLogsEnabled(final boolean logsEnabled) { + this.logsEnabled = logsEnabled; } - public boolean isEnableLogs() { - return enableLogs; + public boolean getLogsEnabled() { + return logsEnabled; } public void setMinimumBreadcrumbLevel(final @Nullable Level minimumBreadcrumbLevel) { diff --git a/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt b/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt index 29dbaeb3688..215923163ee 100644 --- a/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt +++ b/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt @@ -41,7 +41,7 @@ class SentryHandlerTest { val transport: ITransport = mock(), contextTags: List? = null, printfStyle: Boolean? = null, - enableLogs: Boolean? = true, + logsEnabled: Boolean? = true, ) { var logger: Logger var handler: SentryHandler @@ -60,8 +60,8 @@ class SentryHandlerTest { handler.setMinimumBreadcrumbLevel(minimumBreadcrumbLevel) handler.setMinimumEventLevel(minimumEventLevel) handler.setMinimumLevel(minimumLevel) - if (enableLogs != null) { - handler.setEnableLogs(enableLogs) + if (logsEnabled != null) { + handler.setLogsEnabled(logsEnabled) } if (printfStyle == true) { handler.setPrintfStyle(printfStyle) @@ -323,12 +323,12 @@ class SentryHandlerTest { @Test fun `fetches configuration from logging dot properties`() { - fixture = Fixture(configureWithLogManager = true, enableLogs = null) + fixture = Fixture(configureWithLogManager = true, logsEnabled = null) assertEquals(Level.CONFIG, fixture.handler.minimumBreadcrumbLevel) assertEquals(Level.WARNING, fixture.handler.minimumEventLevel) assertEquals(Level.ALL, fixture.handler.level) assertTrue(fixture.handler.isPrintfStyle) - assertTrue(fixture.handler.isEnableLogs) + assertTrue(fixture.handler.logsEnabled) fixture.logger.info("this should be captured as a log") Sentry.flush(10) @@ -436,9 +436,9 @@ class SentryHandlerTest { @Test fun `does not capture logs by default`() { - fixture = Fixture(enableLogs = null) + fixture = Fixture(logsEnabled = null) - assertFalse(fixture.handler.isEnableLogs) + assertFalse(fixture.handler.logsEnabled) fixture.logger.info("this should not be captured as a log") Sentry.flush(10) @@ -447,9 +447,9 @@ class SentryHandlerTest { @Test fun `captures logs when enabled through Java`() { - fixture = Fixture(enableLogs = true) + fixture = Fixture(logsEnabled = true) - assertTrue(fixture.handler.isEnableLogs) + assertTrue(fixture.handler.logsEnabled) fixture.logger.info("this should be captured as a log") Sentry.flush(10) @@ -467,7 +467,7 @@ class SentryHandlerTest { Fixture( minimumBreadcrumbLevel = Level.INFO, minimumEventLevel = Level.SEVERE, - enableLogs = false, + logsEnabled = false, ) fixture.logger.info("this should be a breadcrumb") @@ -491,7 +491,7 @@ class SentryHandlerTest { Fixture( minimumBreadcrumbLevel = Level.INFO, minimumEventLevel = Level.SEVERE, - enableLogs = true, + logsEnabled = true, ) fixture.logger.info(null as String?) diff --git a/sentry-jul/src/test/resources/logging.properties b/sentry-jul/src/test/resources/logging.properties index 25ac65e1f66..66d5b40360f 100644 --- a/sentry-jul/src/test/resources/logging.properties +++ b/sentry-jul/src/test/resources/logging.properties @@ -3,6 +3,6 @@ io.sentry.jul.SentryHandler.minimumEventLevel=WARNING io.sentry.jul.SentryHandler.minimumBreadcrumbLevel=CONFIG io.sentry.jul.SentryHandler.minimumLevel=CONFIG io.sentry.jul.SentryHandler.printfStyle=true -io.sentry.jul.SentryHandler.enableLogs=true +io.sentry.jul.SentryHandler.logsEnabled=true jul.SentryHandlerTest.handlers=java.util.logging.ConsoleHandler, io.sentry.jul.SentryHandler diff --git a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java index 39d17a30c11..a8f1411b021 100644 --- a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java +++ b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java @@ -55,7 +55,7 @@ public class SentryAppender extends AbstractAppender { private @NotNull Level minimumBreadcrumbLevel = Level.INFO; private @NotNull Level minimumEventLevel = Level.ERROR; private @NotNull Level minimumLevel = Level.INFO; - private final boolean enableLogs; + private final boolean logsEnabled; private final @Nullable Boolean debug; private final @NotNull IScopes scopes; private final @Nullable List contextTags; @@ -126,7 +126,7 @@ public SentryAppender( final @Nullable Level minimumBreadcrumbLevel, final @Nullable Level minimumEventLevel, final @Nullable Level minimumLevel, - final boolean enableLogs, + final boolean logsEnabled, final @Nullable Boolean debug, final @Nullable ITransportFactory transportFactory, final @NotNull IScopes scopes, @@ -142,7 +142,7 @@ public SentryAppender( if (minimumLevel != null) { this.minimumLevel = minimumLevel; } - this.enableLogs = enableLogs; + this.logsEnabled = logsEnabled; this.debug = debug; this.transportFactory = transportFactory; this.scopes = scopes; @@ -188,7 +188,7 @@ public SentryAppender( @Nullable @PluginAttribute("minimumBreadcrumbLevel") final Level minimumBreadcrumbLevel, @Nullable @PluginAttribute("minimumEventLevel") final Level minimumEventLevel, @Nullable @PluginAttribute("minimumLevel") final Level minimumLevel, - @Nullable @PluginAttribute("enableLogs") final Boolean enableLogs, + @Nullable @PluginAttribute("logsEnabled") final Boolean logsEnabled, @Nullable @PluginAttribute("dsn") final String dsn, @Nullable @PluginAttribute("debug") final Boolean debug, @Nullable @PluginElement("filter") final Filter filter, @@ -205,7 +205,7 @@ public SentryAppender( minimumBreadcrumbLevel, minimumEventLevel, minimumLevel, - Boolean.TRUE.equals(enableLogs), + Boolean.TRUE.equals(logsEnabled), debug, null, ScopesAdapter.getInstance(), @@ -257,7 +257,7 @@ void start(final @NotNull Sentry.OptionsConfiguration optionsConf @Override public void append(final @NotNull LogEvent eventObject) { - if (enableLogs && eventObject.getLevel().isMoreSpecificThan(minimumLevel)) { + if (logsEnabled && eventObject.getLevel().isMoreSpecificThan(minimumLevel)) { captureLog(eventObject); } if (eventObject.getLevel().isMoreSpecificThan(minimumEventLevel)) { diff --git a/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt b/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt index fe5d3f4112c..0ae42c6358f 100644 --- a/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt +++ b/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt @@ -62,7 +62,7 @@ class SentryAppenderTest { minimumLevel: Level? = null, debug: Boolean? = null, contextTags: List? = null, - enableLogs: Boolean = true, + logsEnabled: Boolean = true, ): ExtendedLogger { if (transportFactory != null) { this.transportFactory = transportFactory @@ -77,7 +77,7 @@ class SentryAppenderTest { minimumBreadcrumbLevel, minimumEventLevel, minimumLevel, - enableLogs, + logsEnabled, debug, this.transportFactory, ScopesAdapter.getInstance(), @@ -262,7 +262,7 @@ class SentryAppenderTest { @Test fun `does not capture logs when local logs are disabled`() { - val logger = fixture.getSut(enableLogs = false) + val logger = fixture.getSut(logsEnabled = false) logger.info("this should not be captured as a log") Sentry.flush(10) @@ -272,7 +272,7 @@ class SentryAppenderTest { @Test fun `captures logs when local logs are enabled`() { - val logger = fixture.getSut(enableLogs = true) + val logger = fixture.getSut(logsEnabled = true) logger.info("this should be captured as a log") Sentry.flush(10) @@ -291,7 +291,7 @@ class SentryAppenderTest { fixture.getSut( minimumBreadcrumbLevel = Level.INFO, minimumEventLevel = Level.ERROR, - enableLogs = false, + logsEnabled = false, ) logger.info("this should be a breadcrumb") diff --git a/sentry-logback/api/sentry-logback.api b/sentry-logback/api/sentry-logback.api index 8d697f1b945..faf3e978790 100644 --- a/sentry-logback/api/sentry-logback.api +++ b/sentry-logback/api/sentry-logback.api @@ -11,12 +11,12 @@ public class io/sentry/logback/SentryAppender : ch/qos/logback/core/Unsynchroniz protected fun captureLog (Lch/qos/logback/classic/spi/ILoggingEvent;)V protected fun createBreadcrumb (Lch/qos/logback/classic/spi/ILoggingEvent;)Lio/sentry/Breadcrumb; protected fun createEvent (Lch/qos/logback/classic/spi/ILoggingEvent;)Lio/sentry/SentryEvent; + public fun getLogsEnabled ()Z public fun getMinimumBreadcrumbLevel ()Lch/qos/logback/classic/Level; public fun getMinimumEventLevel ()Lch/qos/logback/classic/Level; public fun getMinimumLevel ()Lch/qos/logback/classic/Level; - public fun isEnableLogs ()Z - public fun setEnableLogs (Z)V public fun setEncoder (Lch/qos/logback/core/encoder/Encoder;)V + public fun setLogsEnabled (Z)V public fun setMinimumBreadcrumbLevel (Lch/qos/logback/classic/Level;)V public fun setMinimumEventLevel (Lch/qos/logback/classic/Level;)V public fun setMinimumLevel (Lch/qos/logback/classic/Level;)V diff --git a/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java b/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java index 2beca04e82f..1a46f9bb2ae 100644 --- a/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java +++ b/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java @@ -52,7 +52,7 @@ public class SentryAppender extends UnsynchronizedAppenderBase { private @NotNull Level minimumBreadcrumbLevel = Level.INFO; private @NotNull Level minimumEventLevel = Level.ERROR; private @NotNull Level minimumLevel = Level.INFO; - private boolean enableLogs = false; + private boolean logsEnabled = false; private @Nullable Encoder encoder; static { @@ -88,7 +88,7 @@ public void start() { @Override protected void append(@NotNull ILoggingEvent eventObject) { - if (enableLogs && eventObject.getLevel().isGreaterOrEqual(minimumLevel)) { + if (logsEnabled && eventObject.getLevel().isGreaterOrEqual(minimumLevel)) { captureLog(eventObject); } if (eventObject.getLevel().isGreaterOrEqual(minimumEventLevel)) { @@ -323,12 +323,12 @@ public void setMinimumLevel(final @Nullable Level minimumLevel) { return minimumLevel; } - public void setEnableLogs(final boolean enableLogs) { - this.enableLogs = enableLogs; + public void setLogsEnabled(final boolean logsEnabled) { + this.logsEnabled = logsEnabled; } - public boolean isEnableLogs() { - return enableLogs; + public boolean getLogsEnabled() { + return logsEnabled; } @ApiStatus.Internal diff --git a/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt b/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt index 153fcb2f635..9ff55be8f57 100644 --- a/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt +++ b/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt @@ -55,7 +55,7 @@ class SentryAppenderTest { contextTags: List? = null, encoder: Encoder? = null, sendDefaultPii: Boolean = false, - enableLogs: Boolean = false, + logsEnabled: Boolean = false, options: SentryOptions = SentryOptions(), startLater: Boolean = false, ) { @@ -81,7 +81,7 @@ class SentryAppenderTest { appender.setMinimumBreadcrumbLevel(minimumBreadcrumbLevel) appender.setMinimumEventLevel(minimumEventLevel) appender.setMinimumLevel(minimumLevel) - appender.setEnableLogs(enableLogs) + appender.setLogsEnabled(logsEnabled) appender.context = loggerContext appender.setTransportFactory(transportFactory) encoder?.context = loggerContext @@ -325,9 +325,9 @@ class SentryAppenderTest { @Test fun `does not capture logs by default`() { - fixture = Fixture(enableLogs = false) + fixture = Fixture(logsEnabled = false) - assertFalse(fixture.appender.isEnableLogs) + assertFalse(fixture.appender.logsEnabled) fixture.logger.info("this should not be captured as a log") Sentry.flush(10) @@ -336,9 +336,9 @@ class SentryAppenderTest { @Test fun `captures logs when local logs are enabled`() { - fixture = Fixture(enableLogs = true) + fixture = Fixture(logsEnabled = true) - assertTrue(fixture.appender.isEnableLogs) + assertTrue(fixture.appender.logsEnabled) fixture.logger.info("this should be captured as a log") Sentry.flush(10) @@ -356,7 +356,7 @@ class SentryAppenderTest { Fixture( minimumBreadcrumbLevel = Level.INFO, minimumEventLevel = Level.ERROR, - enableLogs = false, + logsEnabled = false, ) fixture.logger.info("this should be a breadcrumb") @@ -376,7 +376,7 @@ class SentryAppenderTest { @Test fun `converts trace log level to Sentry log level`() { - fixture = Fixture(minimumLevel = Level.TRACE, enableLogs = true) + fixture = Fixture(minimumLevel = Level.TRACE, logsEnabled = true) fixture.logger.trace("testing trace level") Sentry.flush(10) @@ -387,7 +387,7 @@ class SentryAppenderTest { @Test fun `converts debug log level to Sentry log level`() { - fixture = Fixture(minimumLevel = Level.DEBUG, enableLogs = true) + fixture = Fixture(minimumLevel = Level.DEBUG, logsEnabled = true) fixture.logger.debug("testing debug level") Sentry.flush(10) @@ -398,7 +398,7 @@ class SentryAppenderTest { @Test fun `converts info log level to Sentry log level`() { - fixture = Fixture(minimumLevel = Level.INFO, enableLogs = true) + fixture = Fixture(minimumLevel = Level.INFO, logsEnabled = true) fixture.logger.info("testing info level") Sentry.flush(10) @@ -409,7 +409,7 @@ class SentryAppenderTest { @Test fun `converts warn log level to Sentry log level`() { - fixture = Fixture(minimumLevel = Level.WARN, enableLogs = true) + fixture = Fixture(minimumLevel = Level.WARN, logsEnabled = true) fixture.logger.warn("testing warn level") Sentry.flush(10) @@ -420,7 +420,7 @@ class SentryAppenderTest { @Test fun `converts error log level to Sentry log level`() { - fixture = Fixture(minimumLevel = Level.ERROR, enableLogs = true) + fixture = Fixture(minimumLevel = Level.ERROR, logsEnabled = true) fixture.logger.error("testing error level") Sentry.flush(10) @@ -431,7 +431,7 @@ class SentryAppenderTest { @Test fun `sends formatted log message if no encoder`() { - fixture = Fixture(minimumLevel = Level.TRACE, enableLogs = true) + fixture = Fixture(minimumLevel = Level.TRACE, logsEnabled = true) fixture.logger.trace("Testing {} level", "TRACE") Sentry.flush(10) @@ -453,7 +453,7 @@ class SentryAppenderTest { fun `does not send formatted log message if encoder is available but sendDefaultPii is off`() { var encoder = PatternLayoutEncoder() encoder.pattern = "encoderadded %msg" - fixture = Fixture(minimumLevel = Level.TRACE, enableLogs = true, encoder = encoder) + fixture = Fixture(minimumLevel = Level.TRACE, logsEnabled = true, encoder = encoder) fixture.logger.trace("Testing {} level", "TRACE") Sentry.flush(10) @@ -476,7 +476,7 @@ class SentryAppenderTest { fixture = Fixture( minimumLevel = Level.TRACE, - enableLogs = true, + logsEnabled = true, sendDefaultPii = true, encoder = encoder, ) @@ -503,7 +503,7 @@ class SentryAppenderTest { fixture = Fixture( minimumLevel = Level.TRACE, - enableLogs = true, + logsEnabled = true, sendDefaultPii = true, encoder = encoder, ) @@ -776,7 +776,7 @@ class SentryAppenderTest { @Test fun `does not set template on log when logging message without parameters`() { - fixture = Fixture(minimumLevel = Level.ERROR, enableLogs = true) + fixture = Fixture(minimumLevel = Level.ERROR, logsEnabled = true) fixture.logger.error("testing message without parameters") Sentry.flush(1000) @@ -793,7 +793,7 @@ class SentryAppenderTest { @Test fun `sets template on log when logging message with parameters`() { - fixture = Fixture(minimumLevel = Level.ERROR, enableLogs = true) + fixture = Fixture(minimumLevel = Level.ERROR, logsEnabled = true) fixture.logger.error("testing message {}", "param") Sentry.flush(1000) @@ -811,7 +811,7 @@ class SentryAppenderTest { @Test fun `sets template on log when logging message with parameters and number of parameters is wrong`() { - fixture = Fixture(minimumLevel = Level.ERROR, enableLogs = true) + fixture = Fixture(minimumLevel = Level.ERROR, logsEnabled = true) fixture.logger.error("testing message {} {} {}", "param1", "param2") Sentry.flush(1000) @@ -839,7 +839,7 @@ class SentryAppenderTest { fixture = Fixture( minimumLevel = Level.ERROR, - enableLogs = true, + logsEnabled = true, encoder = encoder, sendDefaultPii = false, ) @@ -865,7 +865,7 @@ class SentryAppenderTest { fixture = Fixture( minimumLevel = Level.ERROR, - enableLogs = true, + logsEnabled = true, encoder = encoder, sendDefaultPii = true, ) @@ -886,7 +886,8 @@ class SentryAppenderTest { @Test fun `sets properties from MDC as attributes on logs`() { - fixture = Fixture(minimumLevel = Level.INFO, enableLogs = true, contextTags = listOf("someTag")) + fixture = + Fixture(minimumLevel = Level.INFO, logsEnabled = true, contextTags = listOf("someTag")) MDC.put("someTag", "someValue") MDC.put("otherTag", "otherValue") fixture.logger.info("testing MDC properties in logs") diff --git a/sentry-samples/sentry-samples-jul/src/main/resources/logging.properties b/sentry-samples/sentry-samples-jul/src/main/resources/logging.properties index db3026bfb9f..a3381afbc87 100644 --- a/sentry-samples/sentry-samples-jul/src/main/resources/logging.properties +++ b/sentry-samples/sentry-samples-jul/src/main/resources/logging.properties @@ -2,7 +2,7 @@ io.sentry.jul.SentryHandler.minimumEventLevel=INFO io.sentry.jul.SentryHandler.minimumBreadcrumbLevel=CONFIG io.sentry.jul.SentryHandler.minimumLevel=INFO io.sentry.jul.SentryHandler.printfStyle=true -io.sentry.jul.SentryHandler.enableLogs=true +io.sentry.jul.SentryHandler.logsEnabled=true io.sentry.jul.SentryHandler.level=FINEST java.util.logging.ConsoleHandler.level = FINE handlers=io.sentry.jul.SentryHandler diff --git a/sentry-samples/sentry-samples-log4j2/src/main/resources/log4j2.xml b/sentry-samples/sentry-samples-log4j2/src/main/resources/log4j2.xml index 028e449b06a..64479e2155a 100644 --- a/sentry-samples/sentry-samples-log4j2/src/main/resources/log4j2.xml +++ b/sentry-samples/sentry-samples-log4j2/src/main/resources/log4j2.xml @@ -12,7 +12,7 @@ minimumBreadcrumbLevel="DEBUG" minimumEventLevel="WARN" minimumLevel="DEBUG" - enableLogs="true" + logsEnabled="true" debug="true" contextTags="userId,requestId" /> diff --git a/sentry-samples/sentry-samples-logback/src/main/resources/logback.xml b/sentry-samples/sentry-samples-logback/src/main/resources/logback.xml index 196486cf807..bc42723a905 100644 --- a/sentry-samples/sentry-samples-logback/src/main/resources/logback.xml +++ b/sentry-samples/sentry-samples-logback/src/main/resources/logback.xml @@ -14,7 +14,7 @@ userId requestId - true + true WARN diff --git a/sentry-samples/sentry-samples-spring-boot-4-opentelemetry-noagent/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-4-opentelemetry-noagent/src/main/resources/application.properties index d8b1bcd2bb6..c21e62a6285 100644 --- a/sentry-samples/sentry-samples-spring-boot-4-opentelemetry-noagent/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-4-opentelemetry-noagent/src/main/resources/application.properties @@ -15,7 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-4-opentelemetry/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-4-opentelemetry/src/main/resources/application.properties index bf302c6dd05..0867acf41d6 100644 --- a/sentry-samples/sentry-samples-spring-boot-4-opentelemetry/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-4-opentelemetry/src/main/resources/application.properties @@ -15,7 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-4-otlp/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-4-otlp/src/main/resources/application.properties index 05a35327d86..a49f6244ad7 100644 --- a/sentry-samples/sentry-samples-spring-boot-4-otlp/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-4-otlp/src/main/resources/application.properties @@ -16,7 +16,7 @@ sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false sentry.in-app-includes="io.sentry.samples" -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces sentry.profile-lifecycle=TRACE diff --git a/sentry-samples/sentry-samples-spring-boot-4-webflux/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-4-webflux/src/main/resources/application.properties index 2e897e5c714..cb54e513d93 100644 --- a/sentry-samples/sentry-samples-spring-boot-4-webflux/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-4-webflux/src/main/resources/application.properties @@ -10,7 +10,7 @@ sentry.logging.minimum-breadcrumb-level=debug sentry.reactive.thread-local-accessor-enabled=true sentry.traces-sample-rate=1.0 sentry.enable-backpressure-handling=true -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.enable-spotlight=true sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-4/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-4/src/main/resources/application.properties index 40a5843c134..3ba334d8f34 100644 --- a/sentry-samples/sentry-samples-spring-boot-4/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-4/src/main/resources/application.properties @@ -16,7 +16,7 @@ sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false sentry.in-app-includes="io.sentry.samples" -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces sentry.profile-lifecycle=TRACE diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/main/resources/application.properties index 7f5880b741a..1e056aead2c 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/main/resources/application.properties @@ -15,7 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/main/resources/application.properties index 4b80755d846..22b7ced935d 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/main/resources/application.properties @@ -15,7 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties index d71c2c433ab..afd27690ff3 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties @@ -16,7 +16,7 @@ sentry.enable-backpressure-handling=true sentry.enable-spotlight=false sentry.enablePrettySerializationOutput=false sentry.in-app-includes="io.sentry.samples" -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces sentry.profile-lifecycle=TRACE diff --git a/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/src/main/resources/application.properties index af217277c78..5b739ad4047 100644 --- a/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/src/main/resources/application.properties @@ -14,7 +14,7 @@ sentry.debug=true sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-opentelemetry/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-opentelemetry/src/main/resources/application.properties index 404549c12da..ffdfa4fa28b 100644 --- a/sentry-samples/sentry-samples-spring-boot-opentelemetry/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-opentelemetry/src/main/resources/application.properties @@ -14,7 +14,7 @@ sentry.debug=true sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-samples/sentry-samples-spring-boot-webflux-jakarta/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-webflux-jakarta/src/main/resources/application.properties index 45d04440f88..bd1df844351 100644 --- a/sentry-samples/sentry-samples-spring-boot-webflux-jakarta/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-webflux-jakarta/src/main/resources/application.properties @@ -10,7 +10,7 @@ sentry.logging.minimum-breadcrumb-level=debug sentry.reactive.thread-local-accessor-enabled=true sentry.traces-sample-rate=1.0 sentry.enable-backpressure-handling=true -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.enable-spotlight=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 diff --git a/sentry-samples/sentry-samples-spring-boot-webflux/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-webflux/src/main/resources/application.properties index 5e85915a9c9..d8ff798353c 100644 --- a/sentry-samples/sentry-samples-spring-boot-webflux/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-webflux/src/main/resources/application.properties @@ -12,7 +12,7 @@ spring.graphql.graphiql.enabled=true spring.graphql.websocket.path=/graphql spring.graphql.schema.printer.enabled=true sentry.enable-backpressure-handling=true -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.enable-spotlight=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 diff --git a/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties index bce0ce41f53..e51e2076690 100644 --- a/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties @@ -14,7 +14,7 @@ sentry.debug=true sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR sentry.enable-backpressure-handling=true sentry.enable-spotlight=true -sentry.logging.enable-logs=true +sentry.logging.logs-enabled=true sentry.in-app-includes="io.sentry.samples" sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces diff --git a/sentry-spring-boot-4/api/sentry-spring-boot-4.api b/sentry-spring-boot-4/api/sentry-spring-boot-4.api index 0415ffff76e..f86ad82ca82 100644 --- a/sentry-spring-boot-4/api/sentry-spring-boot-4.api +++ b/sentry-spring-boot-4/api/sentry-spring-boot-4.api @@ -57,14 +57,14 @@ public class io/sentry/spring/boot4/SentryProperties$Graphql { public class io/sentry/spring/boot4/SentryProperties$Logging { public fun ()V public fun getLoggers ()Ljava/util/List; + public fun getLogsEnabled ()Z public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level; public fun getMinimumEventLevel ()Lorg/slf4j/event/Level; public fun getMinimumLevel ()Lorg/slf4j/event/Level; - public fun isEnableLogs ()Z public fun isEnabled ()Z - public fun setEnableLogs (Z)V public fun setEnabled (Z)V public fun setLoggers (Ljava/util/List;)V + public fun setLogsEnabled (Z)V public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V public fun setMinimumLevel (Lorg/slf4j/event/Level;)V diff --git a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLogbackInitializer.java b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLogbackInitializer.java index c51e2cda077..b2f498e4401 100644 --- a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLogbackInitializer.java +++ b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLogbackInitializer.java @@ -45,7 +45,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) { if (!isSentryAppenderRegistered(logger)) { final SentryAppender sentryAppender = getSentryAppender(); - sentryAppender.setEnableLogs(sentryProperties.getLogging().isEnableLogs()); + sentryAppender.setLogsEnabled(sentryProperties.getLogging().getLogsEnabled()); Optional.ofNullable(sentryProperties.getLogging().getMinimumBreadcrumbLevel()) .map(slf4jLevel -> Level.toLevel(slf4jLevel.name())) .ifPresent(sentryAppender::setMinimumBreadcrumbLevel); diff --git a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryProperties.java b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryProperties.java index 41358f8cc84..9bc86185ff4 100644 --- a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryProperties.java +++ b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryProperties.java @@ -130,7 +130,7 @@ public static class Logging { private boolean enabled = true; /** Enable/Disable Sentry Logs capture from the auto-configured appender. */ - private boolean enableLogs = false; + private boolean logsEnabled = false; /** Minimum logging level for recording breadcrumbs. */ private @Nullable Level minimumBreadcrumbLevel; @@ -152,12 +152,12 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - public boolean isEnableLogs() { - return enableLogs; + public boolean getLogsEnabled() { + return logsEnabled; } - public void setEnableLogs(boolean enableLogs) { - this.enableLogs = enableLogs; + public void setLogsEnabled(boolean logsEnabled) { + this.logsEnabled = logsEnabled; } public @Nullable Level getMinimumBreadcrumbLevel() { diff --git a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt index 00ee58a5c20..cb01659756f 100644 --- a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt @@ -222,7 +222,7 @@ class SentryAutoConfigurationTest { "integrations now require their own opt-ins.", *emptyArray(), ) - assertThat(it.getBean(SentryProperties::class.java).logging.isEnableLogs).isFalse() + assertThat(it.getBean(SentryProperties::class.java).logging.logsEnabled).isFalse() } } @@ -242,7 +242,7 @@ class SentryAutoConfigurationTest { "their own opt-ins.", *emptyArray(), ) - assertThat(it.getBean(SentryProperties::class.java).logging.isEnableLogs).isFalse() + assertThat(it.getBean(SentryProperties::class.java).logging.logsEnabled).isFalse() } } @@ -340,7 +340,7 @@ class SentryAutoConfigurationTest { "sentry.cron.default-timezone=America/New_York", "sentry.cron.default-failure-issue-threshold=40", "sentry.cron.default-recovery-threshold=50", - "sentry.logging.enable-logs=true", + "sentry.logging.logs-enabled=true", "sentry.strict-trace-continuation=true", "sentry.org-id=12345", ) @@ -397,7 +397,7 @@ class SentryAutoConfigurationTest { assertThat(options.cron!!.defaultTimezone).isEqualTo("America/New_York") assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L) assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L) - assertThat(options.logging.isEnableLogs).isTrue() + assertThat(options.logging.logsEnabled).isTrue() assertThat(options.isStrictTraceContinuation).isEqualTo(true) assertThat(options.orgId).isEqualTo("12345") } diff --git a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLogbackAppenderAutoConfigurationTest.kt b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLogbackAppenderAutoConfigurationTest.kt index be3f7863b03..90e756d59b6 100644 --- a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLogbackAppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLogbackAppenderAutoConfigurationTest.kt @@ -112,7 +112,7 @@ class SentryLogbackAppenderAutoConfigurationTest { "sentry.logging.minimum-event-level=info", "sentry.logging.minimum-breadcrumb-level=debug", "sentry.logging.minimum-level=error", - "sentry.logging.enable-logs=true", + "sentry.logging.logs-enabled=true", ) .run { val appenders = rootLogger.getAppenders(SentryAppender::class.java) @@ -122,7 +122,7 @@ class SentryLogbackAppenderAutoConfigurationTest { assertThat(sentryAppender.minimumBreadcrumbLevel).isEqualTo(Level.DEBUG) assertThat(sentryAppender.minimumEventLevel).isEqualTo(Level.INFO) assertThat(sentryAppender.minimumLevel).isEqualTo(Level.ERROR) - assertThat(sentryAppender.isEnableLogs).isTrue() + assertThat(sentryAppender.logsEnabled).isTrue() } } @@ -131,7 +131,7 @@ class SentryLogbackAppenderAutoConfigurationTest { dsnEnabledRunner.run { val sentryAppender = rootLogger.getAppenders(SentryAppender::class.java).single() - assertThat((sentryAppender as SentryAppender).isEnableLogs).isFalse() + assertThat((sentryAppender as SentryAppender).logsEnabled).isFalse() } } diff --git a/sentry-spring-boot-jakarta/api/sentry-spring-boot-jakarta.api b/sentry-spring-boot-jakarta/api/sentry-spring-boot-jakarta.api index 8ecabe5de92..7a80854d2a1 100644 --- a/sentry-spring-boot-jakarta/api/sentry-spring-boot-jakarta.api +++ b/sentry-spring-boot-jakarta/api/sentry-spring-boot-jakarta.api @@ -57,14 +57,14 @@ public class io/sentry/spring/boot/jakarta/SentryProperties$Graphql { public class io/sentry/spring/boot/jakarta/SentryProperties$Logging { public fun ()V public fun getLoggers ()Ljava/util/List; + public fun getLogsEnabled ()Z public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level; public fun getMinimumEventLevel ()Lorg/slf4j/event/Level; public fun getMinimumLevel ()Lorg/slf4j/event/Level; - public fun isEnableLogs ()Z public fun isEnabled ()Z - public fun setEnableLogs (Z)V public fun setEnabled (Z)V public fun setLoggers (Ljava/util/List;)V + public fun setLogsEnabled (Z)V public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V public fun setMinimumLevel (Lorg/slf4j/event/Level;)V diff --git a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLogbackInitializer.java b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLogbackInitializer.java index fa6cd7a76ce..e7902c99668 100644 --- a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLogbackInitializer.java +++ b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLogbackInitializer.java @@ -45,7 +45,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) { if (!isSentryAppenderRegistered(logger)) { final SentryAppender sentryAppender = getSentryAppender(); - sentryAppender.setEnableLogs(sentryProperties.getLogging().isEnableLogs()); + sentryAppender.setLogsEnabled(sentryProperties.getLogging().getLogsEnabled()); Optional.ofNullable(sentryProperties.getLogging().getMinimumBreadcrumbLevel()) .map(slf4jLevel -> Level.toLevel(slf4jLevel.name())) .ifPresent(sentryAppender::setMinimumBreadcrumbLevel); diff --git a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryProperties.java b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryProperties.java index 223dcce8696..cdfc9229a20 100644 --- a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryProperties.java +++ b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryProperties.java @@ -130,7 +130,7 @@ public static class Logging { private boolean enabled = true; /** Enable/Disable Sentry Logs capture from the auto-configured appender. */ - private boolean enableLogs = false; + private boolean logsEnabled = false; /** Minimum logging level for recording breadcrumbs. */ private @Nullable Level minimumBreadcrumbLevel; @@ -152,12 +152,12 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - public boolean isEnableLogs() { - return enableLogs; + public boolean getLogsEnabled() { + return logsEnabled; } - public void setEnableLogs(boolean enableLogs) { - this.enableLogs = enableLogs; + public void setLogsEnabled(boolean logsEnabled) { + this.logsEnabled = logsEnabled; } public @Nullable Level getMinimumBreadcrumbLevel() { diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt index 1d8b8817bd3..ae0a8fd6afb 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt @@ -225,7 +225,7 @@ class SentryAutoConfigurationTest { "integrations now require their own opt-ins.", *emptyArray(), ) - assertThat(it.getBean(SentryProperties::class.java).logging.isEnableLogs).isFalse() + assertThat(it.getBean(SentryProperties::class.java).logging.logsEnabled).isFalse() } } @@ -245,7 +245,7 @@ class SentryAutoConfigurationTest { "their own opt-ins.", *emptyArray(), ) - assertThat(it.getBean(SentryProperties::class.java).logging.isEnableLogs).isFalse() + assertThat(it.getBean(SentryProperties::class.java).logging.logsEnabled).isFalse() } } @@ -342,7 +342,7 @@ class SentryAutoConfigurationTest { "sentry.cron.default-timezone=America/New_York", "sentry.cron.default-failure-issue-threshold=40", "sentry.cron.default-recovery-threshold=50", - "sentry.logging.enable-logs=true", + "sentry.logging.logs-enabled=true", "sentry.profile-session-sample-rate=1.0", "sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces", "sentry.profile-lifecycle=TRACE", @@ -401,7 +401,7 @@ class SentryAutoConfigurationTest { assertThat(options.cron!!.defaultTimezone).isEqualTo("America/New_York") assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L) assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L) - assertThat(options.logging.isEnableLogs).isTrue() + assertThat(options.logging.logsEnabled).isTrue() assertThat(options.profileSessionSampleRate).isEqualTo(1.0) assertThat(options.profilingTracesDirPath) .startsWith(File("tmp/sentry/profiling-traces").absolutePath) diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfigurationTest.kt index 5dfcd5cd324..fb324265b97 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfigurationTest.kt @@ -112,7 +112,7 @@ class SentryLogbackAppenderAutoConfigurationTest { "sentry.logging.minimum-event-level=info", "sentry.logging.minimum-breadcrumb-level=debug", "sentry.logging.minimum-level=error", - "sentry.logging.enable-logs=true", + "sentry.logging.logs-enabled=true", ) .run { val appenders = rootLogger.getAppenders(SentryAppender::class.java) @@ -122,7 +122,7 @@ class SentryLogbackAppenderAutoConfigurationTest { assertThat(sentryAppender.minimumBreadcrumbLevel).isEqualTo(Level.DEBUG) assertThat(sentryAppender.minimumEventLevel).isEqualTo(Level.INFO) assertThat(sentryAppender.minimumLevel).isEqualTo(Level.ERROR) - assertThat(sentryAppender.isEnableLogs).isTrue() + assertThat(sentryAppender.logsEnabled).isTrue() } } @@ -131,7 +131,7 @@ class SentryLogbackAppenderAutoConfigurationTest { dsnEnabledRunner.run { val sentryAppender = rootLogger.getAppenders(SentryAppender::class.java).single() - assertThat((sentryAppender as SentryAppender).isEnableLogs).isFalse() + assertThat((sentryAppender as SentryAppender).logsEnabled).isFalse() } } diff --git a/sentry-spring-boot/api/sentry-spring-boot.api b/sentry-spring-boot/api/sentry-spring-boot.api index 3a34fcc542d..9aa4f3caf0e 100644 --- a/sentry-spring-boot/api/sentry-spring-boot.api +++ b/sentry-spring-boot/api/sentry-spring-boot.api @@ -53,14 +53,14 @@ public class io/sentry/spring/boot/SentryProperties$Graphql { public class io/sentry/spring/boot/SentryProperties$Logging { public fun ()V public fun getLoggers ()Ljava/util/List; + public fun getLogsEnabled ()Z public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level; public fun getMinimumEventLevel ()Lorg/slf4j/event/Level; public fun getMinimumLevel ()Lorg/slf4j/event/Level; - public fun isEnableLogs ()Z public fun isEnabled ()Z - public fun setEnableLogs (Z)V public fun setEnabled (Z)V public fun setLoggers (Ljava/util/List;)V + public fun setLogsEnabled (Z)V public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V public fun setMinimumLevel (Lorg/slf4j/event/Level;)V diff --git a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryLogbackInitializer.java b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryLogbackInitializer.java index 6997aca3fc8..a064d8e1299 100644 --- a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryLogbackInitializer.java +++ b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryLogbackInitializer.java @@ -45,7 +45,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) { if (!isSentryAppenderRegistered(logger)) { final SentryAppender sentryAppender = getSentryAppender(); - sentryAppender.setEnableLogs(sentryProperties.getLogging().isEnableLogs()); + sentryAppender.setLogsEnabled(sentryProperties.getLogging().getLogsEnabled()); Optional.ofNullable(sentryProperties.getLogging().getMinimumBreadcrumbLevel()) .map(slf4jLevel -> Level.toLevel(slf4jLevel.name())) .ifPresent(sentryAppender::setMinimumBreadcrumbLevel); diff --git a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryProperties.java b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryProperties.java index 876cb552571..f4fc3bb8828 100644 --- a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryProperties.java +++ b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryProperties.java @@ -104,7 +104,7 @@ public static class Logging { private boolean enabled = true; /** Enable/Disable Sentry Logs capture from the auto-configured appender. */ - private boolean enableLogs = false; + private boolean logsEnabled = false; /** Minimum logging level for recording breadcrumbs. */ private @Nullable Level minimumBreadcrumbLevel; @@ -126,12 +126,12 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - public boolean isEnableLogs() { - return enableLogs; + public boolean getLogsEnabled() { + return logsEnabled; } - public void setEnableLogs(boolean enableLogs) { - this.enableLogs = enableLogs; + public void setLogsEnabled(boolean logsEnabled) { + this.logsEnabled = logsEnabled; } public @Nullable Level getMinimumBreadcrumbLevel() { diff --git a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt index 39185e581fc..d9c78311da0 100644 --- a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt @@ -223,7 +223,7 @@ class SentryAutoConfigurationTest { "integrations now require their own opt-ins.", *emptyArray(), ) - assertThat(it.getBean(SentryProperties::class.java).logging.isEnableLogs).isFalse() + assertThat(it.getBean(SentryProperties::class.java).logging.logsEnabled).isFalse() } } @@ -243,7 +243,7 @@ class SentryAutoConfigurationTest { "their own opt-ins.", *emptyArray(), ) - assertThat(it.getBean(SentryProperties::class.java).logging.isEnableLogs).isFalse() + assertThat(it.getBean(SentryProperties::class.java).logging.logsEnabled).isFalse() } } @@ -340,7 +340,7 @@ class SentryAutoConfigurationTest { "sentry.cron.default-timezone=America/New_York", "sentry.cron.default-failure-issue-threshold=40", "sentry.cron.default-recovery-threshold=50", - "sentry.logging.enable-logs=true", + "sentry.logging.logs-enabled=true", "sentry.profile-session-sample-rate=1.0", "sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces", "sentry.profile-lifecycle=TRACE", @@ -399,7 +399,7 @@ class SentryAutoConfigurationTest { assertThat(options.cron!!.defaultTimezone).isEqualTo("America/New_York") assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L) assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L) - assertThat(options.logging.isEnableLogs).isTrue() + assertThat(options.logging.logsEnabled).isTrue() assertThat(options.profileSessionSampleRate).isEqualTo(1.0) assertThat(options.profilingTracesDirPath) .startsWith(File("tmp/sentry/profiling-traces").absolutePath) diff --git a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryLogbackAppenderAutoConfigurationTest.kt b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryLogbackAppenderAutoConfigurationTest.kt index 6117ccf3f8d..f6f24bf67ac 100644 --- a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryLogbackAppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryLogbackAppenderAutoConfigurationTest.kt @@ -112,7 +112,7 @@ class SentryLogbackAppenderAutoConfigurationTest { "sentry.logging.minimum-event-level=info", "sentry.logging.minimum-breadcrumb-level=debug", "sentry.logging.minimum-level=error", - "sentry.logging.enable-logs=true", + "sentry.logging.logs-enabled=true", ) .run { val appenders = rootLogger.getAppenders(SentryAppender::class.java) @@ -122,7 +122,7 @@ class SentryLogbackAppenderAutoConfigurationTest { assertThat(sentryAppender.minimumBreadcrumbLevel).isEqualTo(Level.DEBUG) assertThat(sentryAppender.minimumEventLevel).isEqualTo(Level.INFO) assertThat(sentryAppender.minimumLevel).isEqualTo(Level.ERROR) - assertThat(sentryAppender.isEnableLogs).isTrue() + assertThat(sentryAppender.logsEnabled).isTrue() } } @@ -131,7 +131,7 @@ class SentryLogbackAppenderAutoConfigurationTest { dsnEnabledRunner.run { val sentryAppender = rootLogger.getAppenders(SentryAppender::class.java).single() - assertThat((sentryAppender as SentryAppender).isEnableLogs).isFalse() + assertThat((sentryAppender as SentryAppender).logsEnabled).isFalse() } } From 672bb4aef231303edf8b390af74d5f5477762cbc Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Wed, 30 Sep 2026 12:45:07 +0200 Subject: [PATCH 03/10] test(logback): Use renamed Logs option Update the remaining fixture call to use logsEnabled so the renamed API compiles. Co-Authored-By: Claude --- .../src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt b/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt index 857e4b75747..b3379940195 100644 --- a/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt +++ b/sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt @@ -953,7 +953,7 @@ class SentryAppenderTest { fixture = Fixture( minimumLevel = Level.ERROR, - enableLogs = true, + logsEnabled = true, encoder = encoder, includeUnencodedMessage = true, ) From 9182ef3e4cd402db1ce6cf4ceef25285933fa9b0 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Wed, 30 Sep 2026 15:00:56 +0200 Subject: [PATCH 04/10] fix(spring): Use renamed Logs option in Log4j2 wiring Keep the newly added Log4j2 auto-configuration wiring aligned with the logsEnabled accessor and Spring property introduced by this branch. Co-Authored-By: Claude --- .../java/io/sentry/spring/boot4/SentryLog4j2Initializer.java | 2 +- .../spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt | 3 +-- .../io/sentry/spring/boot/jakarta/SentryLog4j2Initializer.java | 2 +- .../boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLog4j2Initializer.java b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLog4j2Initializer.java index fe2d8a301a8..bb20d47a35a 100644 --- a/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLog4j2Initializer.java +++ b/sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryLog4j2Initializer.java @@ -95,7 +95,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) { toLog4jLevel(sentryProperties.getLogging().getMinimumBreadcrumbLevel()), toLog4jLevel(sentryProperties.getLogging().getMinimumEventLevel()), toLog4jLevel(sentryProperties.getLogging().getMinimumLevel()), - sentryProperties.getLogging().isEnableLogs(), + sentryProperties.getLogging().getLogsEnabled(), null, null, ScopesAdapter.getInstance(), diff --git a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt index 2518b11a402..19de881d611 100644 --- a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt @@ -77,7 +77,6 @@ class SentryLog4j2AppenderAutoConfigurationTest { .withPropertyValues( "sentry.dsn=http://key@localhost/proj", "sentry.logging.enabled=true", - "sentry.logs.enabled=true", ) .withUserConfiguration(MockTransportConfiguration::class.java) @@ -201,7 +200,7 @@ class SentryLog4j2AppenderAutoConfigurationTest { @Test fun `forwards Sentry Logs when enabled`() { - logsRunner.withPropertyValues("sentry.logging.enable-logs=true").run { + logsRunner.withPropertyValues("sentry.logging.logs-enabled=true").run { LogManager.getLogger("io.sentry.spring.boot4.logs-enabled").error("enabled log") Sentry.flush(1000) diff --git a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLog4j2Initializer.java b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLog4j2Initializer.java index 4b2588da8e7..8db89bf9f20 100644 --- a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLog4j2Initializer.java +++ b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryLog4j2Initializer.java @@ -95,7 +95,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) { toLog4jLevel(sentryProperties.getLogging().getMinimumBreadcrumbLevel()), toLog4jLevel(sentryProperties.getLogging().getMinimumEventLevel()), toLog4jLevel(sentryProperties.getLogging().getMinimumLevel()), - sentryProperties.getLogging().isEnableLogs(), + sentryProperties.getLogging().getLogsEnabled(), null, null, ScopesAdapter.getInstance(), diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt index 993398923be..4462b127f77 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt @@ -77,7 +77,6 @@ class SentryLog4j2AppenderAutoConfigurationTest { .withPropertyValues( "sentry.dsn=http://key@localhost/proj", "sentry.logging.enabled=true", - "sentry.logs.enabled=true", ) .withUserConfiguration(MockTransportConfiguration::class.java) @@ -201,7 +200,7 @@ class SentryLog4j2AppenderAutoConfigurationTest { @Test fun `forwards Sentry Logs when enabled`() { - logsRunner.withPropertyValues("sentry.logging.enable-logs=true").run { + logsRunner.withPropertyValues("sentry.logging.logs-enabled=true").run { LogManager.getLogger("io.sentry.spring.boot.jakarta.logs-enabled").error("enabled log") Sentry.flush(1000) From 10c76e24229962a2d57c287f09da47e938daf28e Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Wed, 30 Sep 2026 16:21:41 +0200 Subject: [PATCH 05/10] test(jul): Use renamed Logs option in regression test Keep the null-message resource-bundle regression test aligned with the logsEnabled fixture option introduced by this branch. Co-Authored-By: Claude --- sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt b/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt index 148ca92c66c..9ab96f451e9 100644 --- a/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt +++ b/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt @@ -518,7 +518,7 @@ class SentryHandlerTest { Fixture( minimumBreadcrumbLevel = Level.INFO, minimumEventLevel = Level.SEVERE, - enableLogs = true, + logsEnabled = true, ) val resourceBundle = object : ListResourceBundle() { From 9bb89b8d822e029b4766b8c53369977dfeeec0ad Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 1 Oct 2026 12:19:42 +0200 Subject: [PATCH 06/10] ref(android): Clarify automatic log capture option names Rename the Timber and Logcat options to make it explicit that they control capture into Sentry rather than output to those logging systems. Keep natural property syntax for Kotlin callers and align tests and guidance with the new names. Co-Authored-By: Claude --- .cursor/rules/options.mdc | 6 ++--- .../api/sentry-android-core.api | 8 +++---- .../core/AndroidOptionsInitializer.java | 3 ++- .../android/core/ManifestMetadataReader.java | 8 +++---- .../android/core/SentryAndroidOptions.java | 20 ++++++++--------- .../android/core/SentryLogcatAdapter.java | 2 +- .../core/AndroidOptionsInitializerTest.kt | 4 ++-- .../core/ManifestMetadataReaderTest.kt | 22 +++++++++---------- .../android/core/SentryAndroidOptionsTest.kt | 20 ++++++++--------- .../sentry/android/core/SentryAndroidTest.kt | 6 ++--- .../android/core/SentryLogcatAdapterTest.kt | 18 +++++++-------- 11 files changed, 59 insertions(+), 58 deletions(-) diff --git a/.cursor/rules/options.mdc b/.cursor/rules/options.mdc index 41340ab1ec7..8da17963179 100644 --- a/.cursor/rules/options.mdc +++ b/.cursor/rules/options.mdc @@ -76,7 +76,7 @@ Allows setting options via `AndroidManifest.xml` `` tags. - Add a `static final String` constant for the key - Read it in `applyMetadata()` using `readBool(metadata, logger, CONSTANT, defaultValue)` - Apply automatic-source options directly, for example - `options.setLogcatLogsEnabled(...)` for `io.sentry.logcat.logs.enabled` + `options.setLogcatLogCaptureEnabled(...)` for `io.sentry.logcat.logs.enabled` - Do not add or restore `io.sentry.logs.enabled` or `io.sentry.metrics.enabled`; those aggregate keys are obsolete. @@ -114,8 +114,8 @@ or breadcrumb paths. Current Logs controls are: - Log4j2: appender `logsEnabled` - JUL: handler `logsEnabled` - Spring Boot Logback: `sentry.logging.logs-enabled` -- Timber: `timberLogsEnabled` / `io.sentry.timber.logs.enabled` -- Logcat: `logcatLogsEnabled` / `io.sentry.logcat.logs.enabled` +- Timber: `timberLogCaptureEnabled` / `io.sentry.timber.logs.enabled` +- Logcat: `logcatLogCaptureEnabled` / `io.sentry.logcat.logs.enabled` All source-local options default to `false` and gate only Sentry Logs forwarding. diff --git a/sentry-android-core/api/sentry-android-core.api b/sentry-android-core/api/sentry-android-core.api index e05090a2601..4efe56db85b 100644 --- a/sentry-android-core/api/sentry-android-core.api +++ b/sentry-android-core/api/sentry-android-core.api @@ -429,14 +429,14 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun getBeforeViewHierarchyCaptureCallback ()Lio/sentry/android/core/SentryAndroidOptions$BeforeCaptureCallback; public fun getDebugImagesLoader ()Lio/sentry/android/core/IDebugImagesLoader; public fun getFrameMetricsCollector ()Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector; - public fun getLogcatLogsEnabled ()Z + public fun getLogcatLogCaptureEnabled ()Z public fun getMonotonicTicker ()Lio/sentry/time/MonotonicTicker; public fun getNativeSdkName ()Ljava/lang/String; public fun getNdkAppHangTimeoutIntervalMillis ()J public fun getNdkHandlerStrategy ()I public fun getScreenshot ()Lio/sentry/android/core/SentryScreenshotOptions; public fun getStartupCrashDurationThresholdMillis ()J - public fun getTimberLogsEnabled ()Z + public fun getTimberLogCaptureEnabled ()Z public fun getTombstoneMergeTimeThresholdMillis ()J public fun isAnrEnabled ()Z public fun isAnrProfilingEnabled ()Z @@ -500,7 +500,7 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun setEnableSystemEventBreadcrumbs (Z)V public fun setEnableSystemEventBreadcrumbsExtras (Z)V public fun setFrameMetricsCollector (Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V - public fun setLogcatLogsEnabled (Z)V + public fun setLogcatLogCaptureEnabled (Z)V public fun setMemoryLimiterEnabled (Z)V public fun setNativeHandlerStrategy (Lio/sentry/android/core/NdkHandlerStrategy;)V public fun setNativeSdkName (Ljava/lang/String;)V @@ -508,7 +508,7 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr public fun setReportHistoricalAnrs (Z)V public fun setReportHistoricalMemoryLimiterExits (Z)V public fun setReportHistoricalTombstones (Z)V - public fun setTimberLogsEnabled (Z)V + public fun setTimberLogCaptureEnabled (Z)V public fun setTombstoneEnabled (Z)V public fun setTombstoneMergeTimeThresholdMillis (J)V } diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java b/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java index 28da4b84b04..a69e6bb397a 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java @@ -479,7 +479,8 @@ static void installDefaultIntegrations( } if (isTimberAvailable) { - options.addIntegration(new SentryTimberIntegration(options::getTimberLogsEnabled)); + options.addIntegration( + new SentryTimberIntegration(() -> options.getTimberLogCaptureEnabled())); } options.addIntegration(new AppComponentsBreadcrumbsIntegration(context)); options.addIntegration(new SystemEventsBreadcrumbsIntegration(context)); diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java index 2a6d9db7514..807546b79d7 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java @@ -750,11 +750,11 @@ static void applyMetadata( } } - options.setTimberLogsEnabled( - readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogsEnabled())); + options.setTimberLogCaptureEnabled( + readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogCaptureEnabled())); - options.setLogcatLogsEnabled( - readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogsEnabled())); + options.setLogcatLogCaptureEnabled( + readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogCaptureEnabled())); final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions(); feedbackOptions.setNameRequired( diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java b/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java index d9f9f7ac78c..b88bb6fdf79 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java @@ -76,10 +76,10 @@ public final class SentryAndroidOptions extends SentryOptions { private boolean enableNetworkEventBreadcrumbs = true; /** Enable or disable automatic Sentry Logs capture from Timber. Default is disabled. */ - private boolean timberLogsEnabled = false; + private boolean timberLogCaptureEnabled = false; /** Enable or disable automatic Sentry Logs capture from Logcat. Default is disabled. */ - private boolean logcatLogsEnabled = false; + private boolean logcatLogCaptureEnabled = false; /** * Enables the Auto instrumentation for Activity lifecycle tracing. @@ -511,20 +511,20 @@ public void setEnableNetworkEventBreadcrumbs(boolean enableNetworkEventBreadcrum this.enableNetworkEventBreadcrumbs = enableNetworkEventBreadcrumbs; } - public boolean getTimberLogsEnabled() { - return timberLogsEnabled; + public boolean getTimberLogCaptureEnabled() { + return timberLogCaptureEnabled; } - public void setTimberLogsEnabled(boolean timberLogsEnabled) { - this.timberLogsEnabled = timberLogsEnabled; + public void setTimberLogCaptureEnabled(boolean timberLogCaptureEnabled) { + this.timberLogCaptureEnabled = timberLogCaptureEnabled; } - public boolean getLogcatLogsEnabled() { - return logcatLogsEnabled; + public boolean getLogcatLogCaptureEnabled() { + return logcatLogCaptureEnabled; } - public void setLogcatLogsEnabled(boolean logcatLogsEnabled) { - this.logcatLogsEnabled = logcatLogsEnabled; + public void setLogcatLogCaptureEnabled(boolean logcatLogCaptureEnabled) { + this.logcatLogCaptureEnabled = logcatLogCaptureEnabled; } /** diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java b/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java index f0dac8629ad..64ac3d7d4d1 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/SentryLogcatAdapter.java @@ -55,7 +55,7 @@ private static void addAsLog( final @NotNull ScopesAdapter scopes = ScopesAdapter.getInstance(); final @NotNull SentryOptions options = scopes.getOptions(); if (!(options instanceof SentryAndroidOptions) - || !((SentryAndroidOptions) options).getLogcatLogsEnabled()) { + || !((SentryAndroidOptions) options).getLogcatLogCaptureEnabled()) { return; } final @Nullable String trMessage = tr != null ? tr.getMessage() : null; diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt index 6869464fa74..ebd50c2d755 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt @@ -713,8 +713,8 @@ class AndroidOptionsInitializerTest { } @Test - fun `SentryTimberIntegration receives Timber logs option`() { - fixture.sentryOptions.timberLogsEnabled = true + fun `SentryTimberIntegration receives Timber log capture option`() { + fixture.sentryOptions.timberLogCaptureEnabled = true fixture.initSutWithClassLoader(isTimberAvailable = true) val actual = diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt index 2fa0cedf8fd..56847c247b5 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt @@ -2176,52 +2176,52 @@ class ManifestMetadataReaderTest { } @Test - fun `applyMetadata keeps Timber logs disabled if not found`() { + fun `applyMetadata keeps Timber log capture disabled if not found`() { val context = fixture.getContext() ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertFalse(fixture.options.timberLogsEnabled) + assertFalse(fixture.options.timberLogCaptureEnabled) } @Test - fun `applyMetadata reads Timber logs enabled to options`() { + fun `applyMetadata reads Timber log capture enabled to options`() { val bundle = bundleOf(ManifestMetadataReader.ENABLE_TIMBER_LOGS to true) val context = fixture.getContext(metaData = bundle) ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertTrue(fixture.options.timberLogsEnabled) + assertTrue(fixture.options.timberLogCaptureEnabled) } @Test - fun `applyMetadata keeps Logcat logs disabled if not found`() { + fun `applyMetadata keeps Logcat log capture disabled if not found`() { val context = fixture.getContext() ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertThat(fixture.options.logcatLogsEnabled).isFalse() + assertThat(fixture.options.logcatLogCaptureEnabled).isFalse() } @Test - fun `applyMetadata reads Logcat logs enabled to options`() { + fun `applyMetadata reads Logcat log capture enabled to options`() { val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to true) val context = fixture.getContext(metaData = bundle) ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertThat(fixture.options.logcatLogsEnabled).isTrue() + assertThat(fixture.options.logcatLogCaptureEnabled).isTrue() } @Test - fun `applyMetadata reads Logcat logs disabled to options`() { - fixture.options.logcatLogsEnabled = true + fun `applyMetadata reads Logcat log capture disabled to options`() { + fixture.options.logcatLogCaptureEnabled = true val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to false) val context = fixture.getContext(metaData = bundle) ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) - assertThat(fixture.options.logcatLogsEnabled).isFalse() + assertThat(fixture.options.logcatLogCaptureEnabled).isFalse() } @Test diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt index 9c6114b0326..cc8b9100015 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidOptionsTest.kt @@ -95,31 +95,31 @@ class SentryAndroidOptionsTest { } @Test - fun `Timber logs are disabled by default`() { + fun `Timber log capture is disabled by default`() { val sentryOptions = SentryAndroidOptions() - assertFalse(sentryOptions.timberLogsEnabled) + assertFalse(sentryOptions.timberLogCaptureEnabled) } @Test - fun `Timber logs can be enabled`() { + fun `Timber log capture can be enabled`() { val sentryOptions = SentryAndroidOptions() - sentryOptions.timberLogsEnabled = true + sentryOptions.timberLogCaptureEnabled = true - assertTrue(sentryOptions.timberLogsEnabled) + assertTrue(sentryOptions.timberLogCaptureEnabled) } @Test - fun `Logcat logs are disabled by default`() { - assertThat(SentryAndroidOptions().logcatLogsEnabled).isFalse() + fun `Logcat log capture is disabled by default`() { + assertThat(SentryAndroidOptions().logcatLogCaptureEnabled).isFalse() } @Test - fun `Logcat logs can be enabled`() { + fun `Logcat log capture can be enabled`() { val sentryOptions = SentryAndroidOptions() - sentryOptions.logcatLogsEnabled = true + sentryOptions.logcatLogCaptureEnabled = true - assertThat(sentryOptions.logcatLogsEnabled).isTrue() + assertThat(sentryOptions.logcatLogCaptureEnabled).isTrue() } @Test diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt index 21be0ed68de..14cc13d8441 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt @@ -241,10 +241,10 @@ class SentryAndroidTest { } @Test - fun `auto-installed Timber integration uses Logs option set in configuration callback`() { + fun `auto-installed Timber integration uses log capture option set in configuration callback`() { val logs = mutableListOf() fixture.initSut { options -> - options.timberLogsEnabled = true + options.timberLogCaptureEnabled = true options.logs.beforeSend = SentryOptions.Logs.BeforeSendLogCallback { log -> logs.add(log) @@ -268,7 +268,7 @@ class SentryAndroidTest { val logs = mutableListOf() initForTest(mockContext) { options -> - options.timberLogsEnabled = false + options.timberLogCaptureEnabled = false options.logs.beforeSend = SentryOptions.Logs.BeforeSendLogCallback { log -> logs.add(log) diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt index 0e4717c458c..135c2da6613 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt @@ -28,7 +28,7 @@ class SentryLogcatAdapterTest { val logs = mutableListOf() fun initSut( - logcatLogsEnabled: Boolean? = true, + logcatLogCaptureEnabled: Boolean? = true, metadata: Bundle = Bundle(), options: Sentry.OptionsConfiguration? = null, ) { @@ -39,8 +39,8 @@ class SentryLogcatAdapterTest { breadcrumbs.add(breadcrumb) breadcrumb } - if (logcatLogsEnabled != null) { - it.logcatLogsEnabled = logcatLogsEnabled + if (logcatLogCaptureEnabled != null) { + it.logcatLogCaptureEnabled = logcatLogCaptureEnabled } it.logs.beforeSend = SentryOptions.Logs.BeforeSendLogCallback { logEvent -> @@ -65,8 +65,8 @@ class SentryLogcatAdapterTest { } @Test - fun `Logcat logs are disabled by default while breadcrumbs and Android Log remain enabled`() { - fixture.initSut(logcatLogsEnabled = null) + fun `Logcat log capture is disabled by default while breadcrumbs and Android Log remain enabled`() { + fixture.initSut(logcatLogCaptureEnabled = null) SentryLogcatAdapter.d(tag, commonMsg) @@ -76,8 +76,8 @@ class SentryLogcatAdapterTest { } @Test - fun `Logcat logs can be enabled through Android options`() { - fixture.initSut(logcatLogsEnabled = true) + fun `Logcat log capture can be enabled through Android options`() { + fixture.initSut(logcatLogCaptureEnabled = true) SentryLogcatAdapter.d(tag, commonMsg) @@ -85,9 +85,9 @@ class SentryLogcatAdapterTest { } @Test - fun `Logcat logs can be enabled through manifest metadata`() { + fun `Logcat log capture can be enabled through manifest metadata`() { val metadata = Bundle().apply { putBoolean(ManifestMetadataReader.ENABLE_LOGCAT_LOGS, true) } - fixture.initSut(logcatLogsEnabled = null, metadata = metadata) + fixture.initSut(logcatLogCaptureEnabled = null, metadata = metadata) SentryLogcatAdapter.d(tag, commonMsg) From 599bc3e43e094ddbb1ee0c8cb45c7425900fcaa7 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 1 Oct 2026 13:25:36 +0200 Subject: [PATCH 07/10] ref(logging)!: Add opt-in flags to existing constructors Add the Logs opt-in directly to the existing Log4j2 and Timber constructor signatures instead of retaining compatibility overloads. Document the intentional v9 API changes in the changelog. BREAKING CHANGE: Log4j2 and Timber callers using explicit constructor signatures must pass the new Logs opt-in argument. Co-Authored-By: Claude --- CHANGELOG.md | 9 ++++ .../api/sentry-android-timber.api | 8 +-- .../android/timber/SentryTimberIntegration.kt | 18 ++----- .../sentry/android/timber/SentryTimberTree.kt | 13 +---- sentry-log4j2/api/sentry-log4j2.api | 2 - .../java/io/sentry/log4j2/SentryAppender.java | 49 ++----------------- .../io/sentry/log4j2/SentryAppenderTest.kt | 22 ++------- ...ntryLog4j2AppenderAutoConfigurationTest.kt | 1 + ...ntryLog4j2AppenderAutoConfigurationTest.kt | 1 + 9 files changed, 23 insertions(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f834d3f7fe..59af0f4539d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## Unreleased +### Breaking Changes + +- Add a `logsEnabled` argument to the preferred Log4j2 `SentryAppender` constructor and + `createAppender` factory. Pass `true` to opt in to Sentry Logs capture or `false` to keep it + disabled. ([#5941](https://github.com/getsentry/sentry-java/pull/5941)) +- Add a `logsEnabled` argument to the `SentryTimberIntegration` and `SentryTimberTree` JVM + constructors. It defaults to `false` for Kotlin callers; Java callers using the explicit level + constructors must pass the new argument. ([#5943](https://github.com/getsentry/sentry-java/pull/5943)) + ### Features - Remove the aggregate Sentry Metrics enable flag; `Sentry.metrics()` calls now capture Metrics by default ([#5953](https://github.com/getsentry/sentry-java/pull/5953)) diff --git a/sentry-android-timber/api/sentry-android-timber.api b/sentry-android-timber/api/sentry-android-timber.api index 32a8407e41b..39359028ec1 100644 --- a/sentry-android-timber/api/sentry-android-timber.api +++ b/sentry-android-timber/api/sentry-android-timber.api @@ -9,11 +9,8 @@ public final class io/sentry/android/timber/BuildConfig { public final class io/sentry/android/timber/SentryTimberIntegration : io/sentry/Integration, java/io/Closeable { public fun ()V - public fun (Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;)V - public synthetic fun (Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;Z)V - public fun (Lio/sentry/util/LazyEvaluator$Evaluator;)V - public fun (Z)V + public synthetic fun (Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun close ()V public final fun getLogsEnabled ()Z public final fun getMinBreadcrumbLevel ()Lio/sentry/SentryLevel; @@ -23,9 +20,8 @@ public final class io/sentry/android/timber/SentryTimberIntegration : io/sentry/ } public final class io/sentry/android/timber/SentryTimberTree : timber/log/Timber$Tree { - public fun (Lio/sentry/IScopes;Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;)V - public synthetic fun (Lio/sentry/IScopes;Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lio/sentry/IScopes;Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;Z)V + public synthetic fun (Lio/sentry/IScopes;Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun d (Ljava/lang/String;[Ljava/lang/Object;)V public fun d (Ljava/lang/Throwable;)V public fun d (Ljava/lang/Throwable;Ljava/lang/String;[Ljava/lang/Object;)V diff --git a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt index 93d2104489f..6ed8d6a1832 100644 --- a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt +++ b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt @@ -18,26 +18,14 @@ public class SentryTimberIntegration( public val minEventLevel: SentryLevel = SentryLevel.ERROR, public val minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, public val minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, + logsEnabled: Boolean = false, ) : Integration, Closeable { public val logsEnabled: Boolean get() = logsEnabledProvider.evaluate() - private var logsEnabledProvider: Evaluator = Evaluator { false } + private var logsEnabledProvider: Evaluator = Evaluator { logsEnabled } - public constructor(logsEnabled: Boolean) : this() { - logsEnabledProvider = Evaluator { logsEnabled } - } - - public constructor( - minEventLevel: SentryLevel, - minBreadcrumbLevel: SentryLevel, - minLogsLevel: SentryLogLevel, - logsEnabled: Boolean, - ) : this(minEventLevel, minBreadcrumbLevel, minLogsLevel) { - logsEnabledProvider = Evaluator { logsEnabled } - } - - public constructor(logsEnabledProvider: Evaluator) : this() { + internal constructor(logsEnabledProvider: Evaluator) : this() { this.logsEnabledProvider = logsEnabledProvider } diff --git a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt index 9d3f86fa81d..0dd5df1d70c 100644 --- a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt +++ b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberTree.kt @@ -19,19 +19,8 @@ public class SentryTimberTree( private val minEventLevel: SentryLevel, private val minBreadcrumbLevel: SentryLevel, private val minLogLevel: SentryLogLevel = SentryLogLevel.INFO, + private val logsEnabled: Boolean = false, ) : Timber.Tree() { - private var logsEnabled: Boolean = false - - public constructor( - scopes: IScopes, - minEventLevel: SentryLevel, - minBreadcrumbLevel: SentryLevel, - minLogLevel: SentryLogLevel, - logsEnabled: Boolean, - ) : this(scopes, minEventLevel, minBreadcrumbLevel, minLogLevel) { - this.logsEnabled = logsEnabled - } - private val pendingTag = ThreadLocal() private fun retrieveTag(): String? { diff --git a/sentry-log4j2/api/sentry-log4j2.api b/sentry-log4j2/api/sentry-log4j2.api index 2afe9f1855c..0c9bff9a0af 100644 --- a/sentry-log4j2/api/sentry-log4j2.api +++ b/sentry-log4j2/api/sentry-log4j2.api @@ -6,12 +6,10 @@ public final class io/sentry/log4j2/BuildConfig { public class io/sentry/log4j2/SentryAppender : org/apache/logging/log4j/core/appender/AbstractAppender { public static final field MECHANISM_TYPE Ljava/lang/String; public fun (Ljava/lang/String;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/Boolean;Lio/sentry/ITransportFactory;Lio/sentry/IScopes;[Ljava/lang/String;)V - public fun (Ljava/lang/String;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/Boolean;Lio/sentry/ITransportFactory;Lio/sentry/IScopes;[Ljava/lang/String;)V public fun (Ljava/lang/String;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;ZLjava/lang/Boolean;Lio/sentry/ITransportFactory;Lio/sentry/IScopes;[Ljava/lang/String;)V public fun append (Lorg/apache/logging/log4j/core/LogEvent;)V protected fun captureLog (Lorg/apache/logging/log4j/core/LogEvent;)V public static fun createAppender (Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Boolean;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;)Lio/sentry/log4j2/SentryAppender; - public static fun createAppender (Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/String;Ljava/lang/Boolean;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;)Lio/sentry/log4j2/SentryAppender; protected fun createBreadcrumb (Lorg/apache/logging/log4j/core/LogEvent;)Lio/sentry/Breadcrumb; protected fun createEvent (Lorg/apache/logging/log4j/core/LogEvent;)Lio/sentry/SentryEvent; public fun getMinimumBreadcrumbLevel ()Lorg/apache/logging/log4j/Level; diff --git a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java index 70a3ca4655d..1357d3aab5a 100644 --- a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java +++ b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java @@ -67,7 +67,8 @@ public class SentryAppender extends AbstractAppender { /** * @deprecated This constructor is deprecated. Please use {@link #SentryAppender(String, Filter, - * String, Level, Level, Level, Boolean, ITransportFactory, IScopes, String[])} instead. + * String, Level, Level, Level, boolean, Boolean, ITransportFactory, IScopes, String[])} + * instead. */ @Deprecated @SuppressWarnings("InlineMeSuggester") @@ -88,30 +89,6 @@ public SentryAppender( minimumBreadcrumbLevel, minimumEventLevel, null, - debug, - transportFactory, - scopes, - contextTags); - } - - public SentryAppender( - final @NotNull String name, - final @Nullable Filter filter, - final @Nullable String dsn, - final @Nullable Level minimumBreadcrumbLevel, - final @Nullable Level minimumEventLevel, - final @Nullable Level minimumLevel, - final @Nullable Boolean debug, - final @Nullable ITransportFactory transportFactory, - final @NotNull IScopes scopes, - final @Nullable String[] contextTags) { - this( - name, - filter, - dsn, - minimumBreadcrumbLevel, - minimumEventLevel, - minimumLevel, false, debug, transportFactory, @@ -156,32 +133,12 @@ public SentryAppender( * @param minimumBreadcrumbLevel The min. level of the breadcrumb. * @param minimumEventLevel The min. level of the event. * @param minimumLevel The min. level of the log event. + * @param logsEnabled Whether to capture log events as Sentry Logs. * @param dsn the Sentry DSN. * @param debug if Sentry debug mode should be on * @param filter The filter, if any, to use. * @return The SentryAppender. */ - public static @Nullable SentryAppender createAppender( - final @Nullable String name, - final @Nullable Level minimumBreadcrumbLevel, - final @Nullable Level minimumEventLevel, - final @Nullable Level minimumLevel, - final @Nullable String dsn, - final @Nullable Boolean debug, - final @Nullable Filter filter, - final @Nullable String contextTags) { - return createAppender( - name, - minimumBreadcrumbLevel, - minimumEventLevel, - minimumLevel, - false, - dsn, - debug, - filter, - contextTags); - } - @PluginFactory public static @Nullable SentryAppender createAppender( @Nullable @PluginAttribute("name") final String name, diff --git a/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt b/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt index 0ae42c6358f..2f95ed99a4e 100644 --- a/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt +++ b/sentry-log4j2/src/test/kotlin/io/sentry/log4j2/SentryAppenderTest.kt @@ -310,7 +310,7 @@ class SentryAppenderTest { } @Test - fun `existing constructors default logs to disabled`() { + fun `constructors can opt out of logs capture`() { val scopes = mock() val event = mock() whenever(event.level).thenReturn(Level.INFO) @@ -335,6 +335,7 @@ class SentryAppenderTest { Level.OFF, Level.OFF, Level.INFO, + false, null, null, scopes, @@ -348,24 +349,9 @@ class SentryAppenderTest { } @Test - fun `existing factory and plugin attribute default logs to disabled`() { + fun `plugin attribute defaults logs to disabled`() { val event = mock() whenever(event.level).thenReturn(Level.INFO) - val existingAppender = - spy( - assertNotNull( - SentryAppender.createAppender( - "existing", - Level.OFF, - Level.OFF, - Level.INFO, - null, - null, - null, - null, - ) - ) - ) val pluginDefaultAppender = spy( assertNotNull( @@ -383,10 +369,8 @@ class SentryAppenderTest { ) ) - existingAppender.append(event) pluginDefaultAppender.append(event) - verify(existingAppender, never()).captureLog(event) verify(pluginDefaultAppender, never()).captureLog(event) } diff --git a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt index 19de881d611..b5ead41901d 100644 --- a/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryLog4j2AppenderAutoConfigurationTest.kt @@ -238,6 +238,7 @@ class SentryLog4j2AppenderAutoConfigurationTest { null, null, null, + false, null, null, io.sentry.ScopesAdapter.getInstance(), diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt index 4462b127f77..f9a0c1f24c0 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryLog4j2AppenderAutoConfigurationTest.kt @@ -238,6 +238,7 @@ class SentryLog4j2AppenderAutoConfigurationTest { null, null, null, + false, null, null, io.sentry.ScopesAdapter.getInstance(), From 5bf5511a55e4179ebce32d4093cdbeddab122491 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Fri, 2 Oct 2026 09:24:05 +0200 Subject: [PATCH 08/10] fix(samples): Use Spring logging Logs option Keep structured Logs enabled in the Spring Boot Log4j2 samples after removing the aggregate Logs configuration. Co-Authored-By: Claude --- .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sentry-samples/sentry-samples-spring-boot-4-log4j2/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-4-log4j2/src/main/resources/application.properties index 96ec03757ce..426aac28b27 100644 --- a/sentry-samples/sentry-samples-spring-boot-4-log4j2/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-4-log4j2/src/main/resources/application.properties @@ -17,7 +17,7 @@ sentry.enable-backpressure-handling=true sentry.enable-spotlight=true sentry.enablePrettySerializationOutput=false sentry.in-app-includes="io.sentry.samples" -sentry.logs.enabled=true +sentry.logging.logs-enabled=true sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces sentry.profile-lifecycle=TRACE diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta-log4j2/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-jakarta-log4j2/src/main/resources/application.properties index d413cded851..8bd8046d2d0 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta-log4j2/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-jakarta-log4j2/src/main/resources/application.properties @@ -17,7 +17,7 @@ sentry.enable-backpressure-handling=true sentry.enable-spotlight=false sentry.enablePrettySerializationOutput=false sentry.in-app-includes="io.sentry.samples" -sentry.logs.enabled=true +sentry.logging.logs-enabled=true sentry.profile-session-sample-rate=1.0 sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces sentry.profile-lifecycle=TRACE From 215754dad4661467dafa1a69b56ea31ea2b3d1a9 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Fri, 2 Oct 2026 10:07:00 +0200 Subject: [PATCH 09/10] docs(changelog): Clarify Logs and Metrics migration Classify removal of the aggregate options as breaking changes and list the source-specific opt-ins for automatic Logs capture. Co-Authored-By: Claude --- CHANGELOG.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59af0f4539d..656360de91e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,23 @@ - Add a `logsEnabled` argument to the `SentryTimberIntegration` and `SentryTimberTree` JVM constructors. It defaults to `false` for Kotlin callers; Java callers using the explicit level constructors must pass the new argument. ([#5943](https://github.com/getsentry/sentry-java/pull/5943)) +- Remove the obsolete aggregate Sentry Metrics options `metrics.enabled` and + `options.getMetrics().setEnabled(...)`. Direct `Sentry.metrics()` calls continue to capture + Metrics whenever the SDK is enabled. ([#5953](https://github.com/getsentry/sentry-java/pull/5953)) +- Remove the obsolete aggregate Sentry Logs options `logs.enabled` and + `options.getLogs().setEnabled(...)`. ([#5947](https://github.com/getsentry/sentry-java/pull/5947)) + Direct `Sentry.logger()` calls continue to capture Logs whenever the SDK is enabled. Sentry Logs + capture is disabled by default for every automatic logging integration. Set the applicable + integration-specific option to `true` to opt in: + - Logback appender: `logsEnabled` + - Log4j2 appender: `logsEnabled` + - JUL handler: `io.sentry.jul.SentryHandler.logsEnabled` + - Spring Boot logging auto-configuration: `sentry.logging.logs-enabled` + - Timber: `timberLogCaptureEnabled` or `io.sentry.timber.logs.enabled` manifest metadata + - Logcat: `logcatLogCaptureEnabled` or `io.sentry.logcat.logs.enabled` manifest metadata ### Features -- Remove the aggregate Sentry Metrics enable flag; `Sentry.metrics()` calls now capture Metrics by default ([#5953](https://github.com/getsentry/sentry-java/pull/5953)) -- Remove the aggregate Sentry Logs enable flag; manual `Sentry.logger()` calls now capture Logs by default ([#5947](https://github.com/getsentry/sentry-java/pull/5947)) - Add an explicit Logs opt-in to Spring Boot logging auto-configuration ([#5946](https://github.com/getsentry/sentry-java/pull/5946)) - Add an explicit Logs opt-in to the Android Logcat integration ([#5945](https://github.com/getsentry/sentry-java/pull/5945)) - Add an explicit Logs opt-in to the Android Timber integration ([#5943](https://github.com/getsentry/sentry-java/pull/5943)) From ba9bccc3280864de8ae569a42eebd37ee9624cd1 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Fri, 2 Oct 2026 13:07:10 +0200 Subject: [PATCH 10/10] ref(timber)!: Require explicit Logs opt-in Replace the no-argument SentryTimberIntegration constructor with a boolean overload so manually installed integrations must choose whether to forward Sentry Logs. Keep the lazy evaluator path for auto-installed integrations and clarify the separate Android option and constructor configuration paths. BREAKING CHANGE: SentryTimberIntegration() now requires a logsEnabled argument. Co-Authored-By: Claude --- CHANGELOG.md | 11 +++-- .../sentry/android/core/SentryAndroidTest.kt | 8 +++- .../api/sentry-android-timber.api | 2 +- .../android/timber/SentryTimberIntegration.kt | 47 ++++++++++++++----- .../timber/SentryTimberIntegrationTest.kt | 28 ++++------- 5 files changed, 61 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 656360de91e..cbcfa6c97ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,10 @@ - Add a `logsEnabled` argument to the preferred Log4j2 `SentryAppender` constructor and `createAppender` factory. Pass `true` to opt in to Sentry Logs capture or `false` to keep it disabled. ([#5941](https://github.com/getsentry/sentry-java/pull/5941)) -- Add a `logsEnabled` argument to the `SentryTimberIntegration` and `SentryTimberTree` JVM - constructors. It defaults to `false` for Kotlin callers; Java callers using the explicit level - constructors must pass the new argument. ([#5943](https://github.com/getsentry/sentry-java/pull/5943)) +- Require a `logsEnabled` argument when manually constructing `SentryTimberIntegration` or + `SentryTimberTree`. Replace `SentryTimberIntegration()` with + `SentryTimberIntegration(logsEnabled = false)` in Kotlin or `new SentryTimberIntegration(false)` + in Java to keep Sentry Logs disabled. ([#5943](https://github.com/getsentry/sentry-java/pull/5943)) - Remove the obsolete aggregate Sentry Metrics options `metrics.enabled` and `options.getMetrics().setEnabled(...)`. Direct `Sentry.metrics()` calls continue to capture Metrics whenever the SDK is enabled. ([#5953](https://github.com/getsentry/sentry-java/pull/5953)) @@ -22,7 +23,9 @@ - Log4j2 appender: `logsEnabled` - JUL handler: `io.sentry.jul.SentryHandler.logsEnabled` - Spring Boot logging auto-configuration: `sentry.logging.logs-enabled` - - Timber: `timberLogCaptureEnabled` or `io.sentry.timber.logs.enabled` manifest metadata + - Auto-installed Timber integration: `timberLogCaptureEnabled` or + `io.sentry.timber.logs.enabled` manifest metadata + - Manually installed Timber integration: `logsEnabled` constructor argument - Logcat: `logcatLogCaptureEnabled` or `io.sentry.logcat.logs.enabled` manifest metadata ### Features diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt index 14cc13d8441..70e5cf5c6ca 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt @@ -286,7 +286,13 @@ class SentryAndroidTest { fixture.initSut(autoInit = true) { it.addIntegration(FragmentLifecycleIntegration(ApplicationProvider.getApplicationContext())) - it.addIntegration(SentryTimberIntegration(minEventLevel = FATAL, minBreadcrumbLevel = DEBUG)) + it.addIntegration( + SentryTimberIntegration( + minEventLevel = FATAL, + minBreadcrumbLevel = DEBUG, + logsEnabled = false, + ) + ) it.addIntegration( SystemEventsBreadcrumbsIntegration( diff --git a/sentry-android-timber/api/sentry-android-timber.api b/sentry-android-timber/api/sentry-android-timber.api index 39359028ec1..f130e820f7f 100644 --- a/sentry-android-timber/api/sentry-android-timber.api +++ b/sentry-android-timber/api/sentry-android-timber.api @@ -8,9 +8,9 @@ public final class io/sentry/android/timber/BuildConfig { } public final class io/sentry/android/timber/SentryTimberIntegration : io/sentry/Integration, java/io/Closeable { - public fun ()V public fun (Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;Z)V public synthetic fun (Lio/sentry/SentryLevel;Lio/sentry/SentryLevel;Lio/sentry/SentryLogLevel;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Z)V public fun close ()V public final fun getLogsEnabled ()Z public final fun getMinBreadcrumbLevel ()Lio/sentry/SentryLevel; diff --git a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt index 6ed8d6a1832..f9ef0c308ef 100644 --- a/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt +++ b/sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt @@ -14,20 +14,45 @@ import java.io.Closeable import timber.log.Timber /** Sentry integration for Timber. */ -public class SentryTimberIntegration( - public val minEventLevel: SentryLevel = SentryLevel.ERROR, - public val minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, - public val minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, - logsEnabled: Boolean = false, +public class SentryTimberIntegration +private constructor( + public val minEventLevel: SentryLevel, + public val minBreadcrumbLevel: SentryLevel, + public val minLogsLevel: SentryLogLevel, + private val logsEnabledProvider: Evaluator, ) : Integration, Closeable { - public val logsEnabled: Boolean - get() = logsEnabledProvider.evaluate() + public constructor( + minEventLevel: SentryLevel = SentryLevel.ERROR, + minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, + minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, + logsEnabled: Boolean, + ) : this( + minEventLevel, + minBreadcrumbLevel, + minLogsLevel, + Evaluator { logsEnabled }, + ) - private var logsEnabledProvider: Evaluator = Evaluator { logsEnabled } + public constructor( + logsEnabled: Boolean + ) : this( + SentryLevel.ERROR, + SentryLevel.INFO, + SentryLogLevel.INFO, + logsEnabled, + ) - internal constructor(logsEnabledProvider: Evaluator) : this() { - this.logsEnabledProvider = logsEnabledProvider - } + internal constructor( + logsEnabledProvider: Evaluator + ) : this( + SentryLevel.ERROR, + SentryLevel.INFO, + SentryLogLevel.INFO, + logsEnabledProvider, + ) + + public val logsEnabled: Boolean + get() = logsEnabledProvider.evaluate() private lateinit var tree: SentryTimberTree private lateinit var logger: ILogger diff --git a/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt b/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt index 4fae8bc6855..e569b7a2936 100644 --- a/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt +++ b/sentry-android-timber/src/test/java/io/sentry/android/timber/SentryTimberIntegrationTest.kt @@ -39,22 +39,14 @@ class SentryTimberIntegrationTest { minEventLevel: SentryLevel = SentryLevel.ERROR, minBreadcrumbLevel: SentryLevel = SentryLevel.INFO, minLogsLevel: SentryLogLevel = SentryLogLevel.INFO, - logsEnabled: Boolean? = null, + logsEnabled: Boolean = false, ): SentryTimberIntegration = - if (logsEnabled == null) { - SentryTimberIntegration( - minEventLevel = minEventLevel, - minBreadcrumbLevel = minBreadcrumbLevel, - minLogsLevel = minLogsLevel, - ) - } else { - SentryTimberIntegration( - minEventLevel = minEventLevel, - minBreadcrumbLevel = minBreadcrumbLevel, - minLogsLevel = minLogsLevel, - logsEnabled = logsEnabled, - ) - } + SentryTimberIntegration( + minEventLevel = minEventLevel, + minBreadcrumbLevel = minBreadcrumbLevel, + minLogsLevel = minLogsLevel, + logsEnabled = logsEnabled, + ) } private val fixture = Fixture() @@ -86,8 +78,8 @@ class SentryTimberIntegrationTest { } @Test - fun `Manual integration defaults logs to disabled while capturing events and breadcrumbs`() { - val sut = fixture.getSut() + fun `Manual integration keeps logs disabled when configured false`() { + val sut = SentryTimberIntegration(logsEnabled = false) sut.register(fixture.scopes, fixture.options) assertFalse(sut.logsEnabled) @@ -100,7 +92,7 @@ class SentryTimberIntegrationTest { @Test fun `Manual integration captures logs when enabled`() { - val sut = fixture.getSut(logsEnabled = true) + val sut = SentryTimberIntegration(logsEnabled = true) sut.register(fixture.scopes, fixture.options) assertTrue(sut.logsEnabled)