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

- 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,6 @@ static void applyMetadata(
}
}

options
.getLogs()
.setEnabled(readBool(metadata, logger, ENABLE_LOGS, options.getLogs().isEnabled()));

options.setEnableTimberLogs(
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.isEnableTimberLogs()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +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()
|| !options.getLogs().isEnabled()) {
|| !((SentryAndroidOptions) options).isEnableLogcatLogs()) {
return;
}
final @Nullable String trMessage = tr != null ? tr.getMessage() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1943,31 +1943,6 @@ class ManifestMetadataReaderTest {
assertTrue(fixture.options.inAppExcludes.isEmpty())
}

@Test
fun `applyMetadata reads logs enabled and keep default value if not found`() {
// Arrange
val context = fixture.getContext()

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertFalse(fixture.options.logs.isEnabled)
}

@Test
fun `applyMetadata reads logs enabled to options`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGS to true)
val context = fixture.getContext(metaData = bundle)

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertTrue(fixture.options.logs.isEnabled)
}

@Test
fun `applyMetadata keeps Timber logs disabled if not found`() {
val context = fixture.getContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import java.lang.RuntimeException
import kotlin.test.AfterTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import org.junit.runner.RunWith
import org.robolectric.shadows.ShadowLog

Expand All @@ -40,7 +39,6 @@ class SentryLogcatAdapterTest {
breadcrumbs.add(breadcrumb)
breadcrumb
}
it.logs.isEnabled = true
if (enableLogcatLogs != null) {
it.isEnableLogcatLogs = enableLogcatLogs
}
Expand Down Expand Up @@ -205,26 +203,6 @@ class SentryLogcatAdapterTest {
.assert("$commonMsg wtf exception\n${throwable.message}", SentryLogLevel.FATAL)
}

@Test
fun `do not send logs if logs is disabled`() {
fixture.initSut { it.logs.isEnabled = false }

SentryLogcatAdapter.v(tag, "$commonMsg verbose")
SentryLogcatAdapter.i(tag, "$commonMsg info")
SentryLogcatAdapter.d(tag, "$commonMsg debug")
SentryLogcatAdapter.w(tag, "$commonMsg warning")
SentryLogcatAdapter.e(tag, "$commonMsg error")
SentryLogcatAdapter.wtf(tag, "$commonMsg wtf")
SentryLogcatAdapter.e(tag, "$commonMsg error exception", throwable)
SentryLogcatAdapter.v(tag, "$commonMsg verbose exception", throwable)
SentryLogcatAdapter.i(tag, "$commonMsg info exception", throwable)
SentryLogcatAdapter.d(tag, "$commonMsg debug exception", throwable)
SentryLogcatAdapter.w(tag, "$commonMsg warning exception", throwable)
SentryLogcatAdapter.wtf(tag, "$commonMsg wtf exception", throwable)

assertTrue(fixture.logs.isEmpty())
}

@Test
fun `logs add correct number of breadcrumb`() {
fixture.initSut()
Expand Down
4 changes: 1 addition & 3 deletions sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ public void publish(final @NotNull LogRecord record) {
return;
}
try {
if (enableLogs
&& ScopesAdapter.getInstance().getOptions().getLogs().isEnabled()
&& record.getLevel().intValue() >= minimumLevel.intValue()) {
if (enableLogs && record.getLevel().intValue() >= minimumLevel.intValue()) {
captureLog(record);
}
if (record.getLevel().intValue() >= minimumEventLevel.intValue()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class SentryHandlerTest {
contextTags: List<String>? = null,
printfStyle: Boolean? = null,
enableLogs: Boolean? = true,
enableGlobalLogs: Boolean = true,
) {
var logger: Logger
var handler: SentryHandler
Expand All @@ -51,7 +50,6 @@ class SentryHandlerTest {
val options = SentryOptions()
options.dsn = "http://key@localhost/proj"
options.setTransportFactory { _, _ -> transport }
options.logs.isEnabled = enableGlobalLogs
options.logs.loggerBatchProcessorFactory = ILoggerBatchProcessorFactory { options, client ->
LoggerBatchProcessor(options, client, ImmediateExecutorService())
}
Expand Down Expand Up @@ -438,7 +436,7 @@ class SentryHandlerTest {

@Test
fun `does not capture logs by default`() {
fixture = Fixture(enableLogs = null, enableGlobalLogs = true)
fixture = Fixture(enableLogs = null)

assertFalse(fixture.handler.isEnableLogs)
fixture.logger.info("this should not be captured as a log")
Expand All @@ -449,7 +447,7 @@ class SentryHandlerTest {

@Test
fun `captures logs when enabled through Java`() {
fixture = Fixture(enableLogs = true, enableGlobalLogs = true)
fixture = Fixture(enableLogs = true)

assertTrue(fixture.handler.isEnableLogs)
fixture.logger.info("this should be captured as a log")
Expand All @@ -470,7 +468,6 @@ class SentryHandlerTest {
minimumBreadcrumbLevel = Level.INFO,
minimumEventLevel = Level.SEVERE,
enableLogs = false,
enableGlobalLogs = true,
)

fixture.logger.info("this should be a breadcrumb")
Expand Down
1 change: 0 additions & 1 deletion sentry-jul/src/test/resources/sentry.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
release=release from sentry.properties
logs.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ void start(final @NotNull Sentry.OptionsConfiguration<SentryOptions> optionsConf

@Override
public void append(final @NotNull LogEvent eventObject) {
if (enableLogs
&& scopes.getOptions().getLogs().isEnabled()
&& eventObject.getLevel().isMoreSpecificThan(minimumLevel)) {
if (enableLogs && eventObject.getLevel().isMoreSpecificThan(minimumLevel)) {
captureLog(eventObject);
}
if (eventObject.getLevel().isMoreSpecificThan(minimumEventLevel)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class SentryAppenderTest {
debug: Boolean? = null,
contextTags: List<String>? = null,
enableLogs: Boolean = true,
enableGlobalLogs: Boolean = true,
): ExtendedLogger {
if (transportFactory != null) {
this.transportFactory = transportFactory
Expand Down Expand Up @@ -106,7 +105,6 @@ class SentryAppenderTest {

appender.start(
appender.getOptionsConfiguration { options ->
options.logs.isEnabled = enableGlobalLogs
options.logs.loggerBatchProcessorFactory =
ILoggerBatchProcessorFactory { options, client ->
LoggerBatchProcessor(options, client, ImmediateExecutorService())
Expand Down Expand Up @@ -264,7 +262,7 @@ class SentryAppenderTest {

@Test
fun `does not capture logs when local logs are disabled`() {
val logger = fixture.getSut(enableLogs = false, enableGlobalLogs = true)
val logger = fixture.getSut(enableLogs = false)

logger.info("this should not be captured as a log")
Sentry.flush(10)
Expand All @@ -273,8 +271,8 @@ class SentryAppenderTest {
}

@Test
fun `captures logs when local and aggregate logs are enabled`() {
val logger = fixture.getSut(enableLogs = true, enableGlobalLogs = true)
fun `captures logs when local logs are enabled`() {
val logger = fixture.getSut(enableLogs = true)

logger.info("this should be captured as a log")
Sentry.flush(10)
Expand All @@ -294,7 +292,6 @@ class SentryAppenderTest {
minimumBreadcrumbLevel = Level.INFO,
minimumEventLevel = Level.ERROR,
enableLogs = false,
enableGlobalLogs = true,
)

logger.info("this should be a breadcrumb")
Expand Down Expand Up @@ -397,7 +394,6 @@ class SentryAppenderTest {
fun `plugin attribute enables logs with explicit opt in`() {
initForTest {
it.dsn = "http://key@localhost/proj"
it.logs.isEnabled = true
}
val event = mock<LogEvent>()
whenever(event.level).thenReturn(Level.INFO)
Expand Down
1 change: 0 additions & 1 deletion sentry-log4j2/src/test/resources/sentry.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
release=release from sentry.properties
logs.enabled=true
shutdown-timeout-millis=0
session-flush-timeout-millis=0
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public void start() {

@Override
protected void append(@NotNull ILoggingEvent eventObject) {
if (enableLogs
&& ScopesAdapter.getInstance().getOptions().getLogs().isEnabled()
&& eventObject.getLevel().isGreaterOrEqual(minimumLevel)) {
if (enableLogs && eventObject.getLevel().isGreaterOrEqual(minimumLevel)) {
captureLog(eventObject);
}
if (eventObject.getLevel().isGreaterOrEqual(minimumEventLevel)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class SentryAppenderTest {
encoder: Encoder<ILoggingEvent>? = null,
sendDefaultPii: Boolean = false,
enableLogs: Boolean = false,
enableGlobalLogs: Boolean = enableLogs,
options: SentryOptions = SentryOptions(),
startLater: Boolean = false,
) {
Expand All @@ -73,7 +72,6 @@ class SentryAppenderTest {
this.encoder = encoder
options.dsn = dsn
options.isSendDefaultPii = sendDefaultPii
options.logs.isEnabled = enableGlobalLogs
options.logs.loggerBatchProcessorFactory = ILoggerBatchProcessorFactory { options, client ->
LoggerBatchProcessor(options, client, ImmediateExecutorService())
}
Expand Down Expand Up @@ -326,8 +324,8 @@ class SentryAppenderTest {
}

@Test
fun `does not capture logs by default when aggregate logs are enabled`() {
fixture = Fixture(enableGlobalLogs = true)
fun `does not capture logs by default`() {
fixture = Fixture(enableLogs = false)

assertFalse(fixture.appender.isEnableLogs)
fixture.logger.info("this should not be captured as a log")
Expand All @@ -337,7 +335,7 @@ class SentryAppenderTest {
}

@Test
fun `captures logs when local and aggregate logs are enabled`() {
fun `captures logs when local logs are enabled`() {
fixture = Fixture(enableLogs = true)

assertTrue(fixture.appender.isEnableLogs)
Expand All @@ -358,7 +356,7 @@ class SentryAppenderTest {
Fixture(
minimumBreadcrumbLevel = Level.INFO,
minimumEventLevel = Level.ERROR,
enableGlobalLogs = true,
enableLogs = false,
)

fixture.logger.info("this should be a breadcrumb")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@
android:name="io.sentry.debug"
android:value="${sentryDebug}" />

<!-- how to enable Sentry Logs (Sentry.logger() calls are dropped unless this is on)-->
<!-- how to enable Sentry Logs capture from Timber-->
<meta-data
android:name="io.sentry.logs.enabled"
android:name="io.sentry.timber.logs.enabled"
android:value="true" />

<!-- how to enable Sentry Logs capture from Logcat-->
<meta-data
android:name="io.sentry.logcat.logs.enabled"
android:value="true" />

<!-- how to disable verbose logging of the session replay feature-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public static void main(String[] args) throws InterruptedException {
// }
// });

options.getLogs().setEnabled(true);
});

Sentry.addBreadcrumb(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ debug=true
environment=staging
in-app-includes=io.sentry.samples
context-tags=userId,requestId
logs.enabled=true
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
in-app-includes="io.sentry.samples"
logs.enabled=true
debug=true
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<dsn>https://502f25099c204a2fbf4cb16edc5975d1@o447951.ingest.sentry.io/5428563</dsn>
<contextTag>userId</contextTag>
<contextTag>requestId</contextTag>
<logs>
<enabled>true</enabled>
</logs>
</options>
<enableLogs>true</enableLogs>
<!-- Demonstrates how to modify the minimum values -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ 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.enable-logs=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 @@ -10,7 +10,6 @@ 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.logs.enabled=true
sentry.logging.enable-logs=true
sentry.enable-spotlight=true
sentry.profile-session-sample-rate=1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ 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.enable-logs=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 @@ -15,7 +15,6 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ 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.enable-logs=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 @@ -14,7 +14,6 @@ sentry.debug=true
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
Expand Down
Loading
Loading