Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- 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))
- Add an explicit Logs opt-in to the JUL handler ([#5942](https://github.com/getsentry/sentry-java/pull/5942))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.in-app-includes="io.sentry.samples"
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sentry.reactive.thread-local-accessor-enabled=true
sentry.traces-sample-rate=1.0
sentry.enable-backpressure-handling=true
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.enable-spotlight=true
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.in-app-includes="io.sentry.samples"
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sentry.enable-spotlight=false
sentry.enablePrettySerializationOutput=false
sentry.in-app-includes="io.sentry.samples"
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sentry.reactive.thread-local-accessor-enabled=true
sentry.traces-sample-rate=1.0
sentry.enable-backpressure-handling=true
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.enable-spotlight=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ spring.graphql.websocket.path=/graphql
spring.graphql.schema.printer.enabled=true
sentry.enable-backpressure-handling=true
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.enable-spotlight=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.logs.enabled=true
sentry.logging.enable-logs=true
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
Expand Down
2 changes: 2 additions & 0 deletions sentry-spring-boot-4/api/sentry-spring-boot-4.api
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public class io/sentry/spring/boot4/SentryProperties$Logging {
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 setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) {
if (!isSentryAppenderRegistered(logger)) {
final SentryAppender sentryAppender = getSentryAppender();

sentryAppender.setEnableLogs(sentryProperties.getLogging().isEnableLogs());
Optional.ofNullable(sentryProperties.getLogging().getMinimumBreadcrumbLevel())
.map(slf4jLevel -> Level.toLevel(slf4jLevel.name()))
.ifPresent(sentryAppender::setMinimumBreadcrumbLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public static class Logging {
/** Enable/Disable logging auto-configuration. */
private boolean enabled = true;

/** Enable/Disable Sentry Logs capture from the auto-configured appender. */
private boolean enableLogs = false;

/** Minimum logging level for recording breadcrumbs. */
private @Nullable Level minimumBreadcrumbLevel;

Expand All @@ -149,6 +152,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isEnableLogs() {
return enableLogs;
}

public void setEnableLogs(boolean enableLogs) {
this.enableLogs = enableLogs;
}

public @Nullable Level getMinimumBreadcrumbLevel() {
return minimumBreadcrumbLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class SentryAutoConfigurationTest {
"sentry.cron.default-failure-issue-threshold=40",
"sentry.cron.default-recovery-threshold=50",
"sentry.logs.enabled=true",
"sentry.logging.enable-logs=true",
"sentry.strict-trace-continuation=true",
"sentry.org-id=12345",
)
Expand Down Expand Up @@ -301,6 +302,7 @@ class SentryAutoConfigurationTest {
assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L)
assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L)
assertThat(options.logs.isEnabled).isEqualTo(true)
assertThat(options.logging.isEnableLogs).isTrue()
assertThat(options.isStrictTraceContinuation).isEqualTo(true)
assertThat(options.orgId).isEqualTo("12345")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +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",
)
.run {
val appenders = rootLogger.getAppenders(SentryAppender::class.java)
Expand All @@ -121,9 +122,19 @@ class SentryLogbackAppenderAutoConfigurationTest {
assertThat(sentryAppender.minimumBreadcrumbLevel).isEqualTo(Level.DEBUG)
assertThat(sentryAppender.minimumEventLevel).isEqualTo(Level.INFO)
assertThat(sentryAppender.minimumLevel).isEqualTo(Level.ERROR)
assertThat(sentryAppender.isEnableLogs).isTrue()
}
}

@Test
fun `SentryAppender Logs are disabled by default`() {
dsnEnabledRunner.run {
val sentryAppender = rootLogger.getAppenders(SentryAppender::class.java).single()

assertThat((sentryAppender as SentryAppender).isEnableLogs).isFalse()
}
}

@Test
fun `does not configure SentryAppender when logging is disabled`() {
contextRunner.withPropertyValues("sentry.logging.enabled=false").run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public class io/sentry/spring/boot/jakarta/SentryProperties$Logging {
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 setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) {
if (!isSentryAppenderRegistered(logger)) {
final SentryAppender sentryAppender = getSentryAppender();

sentryAppender.setEnableLogs(sentryProperties.getLogging().isEnableLogs());
Optional.ofNullable(sentryProperties.getLogging().getMinimumBreadcrumbLevel())
.map(slf4jLevel -> Level.toLevel(slf4jLevel.name()))
.ifPresent(sentryAppender::setMinimumBreadcrumbLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public static class Logging {
/** Enable/Disable logging auto-configuration. */
private boolean enabled = true;

/** Enable/Disable Sentry Logs capture from the auto-configured appender. */
private boolean enableLogs = false;

/** Minimum logging level for recording breadcrumbs. */
private @Nullable Level minimumBreadcrumbLevel;

Expand All @@ -149,6 +152,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isEnableLogs() {
return enableLogs;
}

public void setEnableLogs(boolean enableLogs) {
this.enableLogs = enableLogs;
}

public @Nullable Level getMinimumBreadcrumbLevel() {
return minimumBreadcrumbLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class SentryAutoConfigurationTest {
"sentry.cron.default-failure-issue-threshold=40",
"sentry.cron.default-recovery-threshold=50",
"sentry.logs.enabled=true",
"sentry.logging.enable-logs=true",
"sentry.profile-session-sample-rate=1.0",
"sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces",
"sentry.profile-lifecycle=TRACE",
Expand Down Expand Up @@ -305,6 +306,7 @@ class SentryAutoConfigurationTest {
assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L)
assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L)
assertThat(options.logs.isEnabled).isEqualTo(true)
assertThat(options.logging.isEnableLogs).isTrue()
assertThat(options.profileSessionSampleRate).isEqualTo(1.0)
assertThat(options.profilingTracesDirPath)
.startsWith(File("tmp/sentry/profiling-traces").absolutePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +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",
)
.run {
val appenders = rootLogger.getAppenders(SentryAppender::class.java)
Expand All @@ -121,9 +122,19 @@ class SentryLogbackAppenderAutoConfigurationTest {
assertThat(sentryAppender.minimumBreadcrumbLevel).isEqualTo(Level.DEBUG)
assertThat(sentryAppender.minimumEventLevel).isEqualTo(Level.INFO)
assertThat(sentryAppender.minimumLevel).isEqualTo(Level.ERROR)
assertThat(sentryAppender.isEnableLogs).isTrue()
}
}

@Test
fun `SentryAppender Logs are disabled by default`() {
dsnEnabledRunner.run {
val sentryAppender = rootLogger.getAppenders(SentryAppender::class.java).single()

assertThat((sentryAppender as SentryAppender).isEnableLogs).isFalse()
}
}

@Test
fun `does not configure SentryAppender when logging is disabled`() {
contextRunner.withPropertyValues("sentry.logging.enabled=false").run {
Expand Down
2 changes: 2 additions & 0 deletions sentry-spring-boot/api/sentry-spring-boot.api
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public class io/sentry/spring/boot/SentryProperties$Logging {
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 setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void onApplicationEvent(final @NotNull ApplicationEvent event) {
if (!isSentryAppenderRegistered(logger)) {
final SentryAppender sentryAppender = getSentryAppender();

sentryAppender.setEnableLogs(sentryProperties.getLogging().isEnableLogs());
Optional.ofNullable(sentryProperties.getLogging().getMinimumBreadcrumbLevel())
.map(slf4jLevel -> Level.toLevel(slf4jLevel.name()))
.ifPresent(sentryAppender::setMinimumBreadcrumbLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public static class Logging {
/** Enable/Disable logging auto-configuration. */
private boolean enabled = true;

/** Enable/Disable Sentry Logs capture from the auto-configured appender. */
private boolean enableLogs = false;

/** Minimum logging level for recording breadcrumbs. */
private @Nullable Level minimumBreadcrumbLevel;

Expand All @@ -123,6 +126,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isEnableLogs() {
return enableLogs;
}

public void setEnableLogs(boolean enableLogs) {
this.enableLogs = enableLogs;
}

public @Nullable Level getMinimumBreadcrumbLevel() {
return minimumBreadcrumbLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class SentryAutoConfigurationTest {
"sentry.cron.default-failure-issue-threshold=40",
"sentry.cron.default-recovery-threshold=50",
"sentry.logs.enabled=true",
"sentry.logging.enable-logs=true",
"sentry.profile-session-sample-rate=1.0",
"sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces",
"sentry.profile-lifecycle=TRACE",
Expand Down Expand Up @@ -303,6 +304,7 @@ class SentryAutoConfigurationTest {
assertThat(options.cron!!.defaultFailureIssueThreshold).isEqualTo(40L)
assertThat(options.cron!!.defaultRecoveryThreshold).isEqualTo(50L)
assertThat(options.logs.isEnabled).isEqualTo(true)
assertThat(options.logging.isEnableLogs).isTrue()
assertThat(options.profileSessionSampleRate).isEqualTo(1.0)
assertThat(options.profilingTracesDirPath)
.startsWith(File("tmp/sentry/profiling-traces").absolutePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +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",
)
.run {
val appenders = rootLogger.getAppenders(SentryAppender::class.java)
Expand All @@ -121,9 +122,19 @@ class SentryLogbackAppenderAutoConfigurationTest {
assertThat(sentryAppender.minimumBreadcrumbLevel).isEqualTo(Level.DEBUG)
assertThat(sentryAppender.minimumEventLevel).isEqualTo(Level.INFO)
assertThat(sentryAppender.minimumLevel).isEqualTo(Level.ERROR)
assertThat(sentryAppender.isEnableLogs).isTrue()
}
}

@Test
fun `SentryAppender Logs are disabled by default`() {
dsnEnabledRunner.run {
val sentryAppender = rootLogger.getAppenders(SentryAppender::class.java).single()

assertThat((sentryAppender as SentryAppender).isEnableLogs).isFalse()
}
}

@Test
fun `does not configure SentryAppender when logging is disabled`() {
contextRunner.withPropertyValues("sentry.logging.enabled=false").run {
Expand Down
Loading