Skip to content

test(log4j2): [Sample Tests 30] Move the log4j2 sample's system test into sentry-log4j2 - #6322

Draft
runningcode wants to merge 1 commit into
no/spring-integration-testfrom
no/log4j2-integration-test
Draft

runningcode wants to merge 1 commit into
no/spring-integration-testfrom
no/log4j2-integration-test

Conversation

@runningcode

@runningcode runningcode commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Moves sentry-samples-log4j2's system test into sentry-log4j2 as SentryAppenderIntegrationTest, the log4j2 version of the logback test in #6268. The sample's test ran its JAR against the Python mock server. The new test configures the Sentry appender from XML in-process and checks what reaches MockSentryServer:

  • the warning event, with its userId context tag and feature flag;
  • the error, with its RuntimeException and the debug and info breadcrumbs;
  • the logs, with the scope's attributes.

Two details:

  • XML configuration: the config is a non-default resource, sentry-appender-integration-test.xml, so it covers how log4j2.xml binds the appender's attributes. The DSN reaches it through a ${sys:...} lookup. The test builds a LoggerContext of its own from the file, so SentryAppenderTest's context keeps its configuration.
  • Logs: the appender has no attribute to enable them. The sample enabled them in sentry.properties, so the test uses the same external-configuration path, through the sentry.logs.enabled system property.

With no system tests left, the sample comes off the runner and the backend workflow. It also drops the Kotlin plugin, which only the test needed. sentry-log4j2 gets Truth as a test dependency.

💡 Motivation and Context

The log4j2 appender's XML binding now runs in ./gradlew :sentry-log4j2:test, in about 0.2 seconds.

💚 How did you test it?

  • The test passes, and so do the module's other 33 tests next to it.
  • Expecting a different warning message makes it fail.
  • :sentry-log4j2:check passes, and the sample's JAR still builds.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

The JUL sample, then the plain console sample.

#skip-changelog

🤖 Generated with Claude Code

This was referenced Oct 20, 2026
@sentry

sentry Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.0 (1) release

⚙️ sentry-android Build Distribution Settings

Adds SentryAppenderIntegrationTest, which configures the Sentry appender
from XML in a logger context of its own and checks what reaches
MockSentryServer: the warning event with its context tag and flag, the
error with its exception and breadcrumbs, and the logs with their
attributes. Logs are enabled through external configuration, as the
sample's sentry.properties does, because the appender has no attribute
for them.

The sample has no system tests left, so it comes off the system-test
runner and the backend workflow, and drops the Kotlin plugin it only
needed for the test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/log4j2-integration-test branch from b5f1f6a to a75e37b Compare October 21, 2026 11:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant