Skip to content

Support logging via native APIs on Android #5911

Description

@triplef

Problem Statement

We would like to use the native sentry_log_*() / sentry_log() APIs in our Android app.

While we can enable logs via SentryAndroidOptions (logs.enabled / io.sentry.logs.enabled manifest key), when the native SDK is initialized through the NDK integration this flag is not passed on:

  • SentryNdk.init() builds the native options from NdkOptions, which only carries DSN, debug, outbox path, release, environment, dist, max breadcrumbs, and SDK name (plus handler strategy, traces sample rate, and app-hang settings) — see SentryNdk.java
  • NdkOptions has no logs-related field — see NdkOptions.java
  • sentry-native options are immutable after sentry_init(), which the NDK integration performs — so the app cannot set enable_logs itself afterward.

As a result, enable_logs is always false in the native SDK on Android, and every call to sentry_log_*() / sentry_log() from native code returns SENTRY_LOG_RETURN_DISABLED and is silently dropped — even when the user has explicitly enabled logs in their Android SDK configuration.

Solution Brainstorm

  • Forward options.getLogs().isEnabled() in SentryNdk.init() in sentry-java.
  • Add an enableLogs field to NdkOptions and apply it in the NDK init path via sentry_options_set_enable_logs().
  • Possibly also forward logs_with_attributes and consider routing beforeSendLog semantics, though the enable_logs flag alone would unblock the feature.

Native logs are sent through the outbox/envelope path, so ingestion should work with the existing transport once the option is enabled.

Metadata

Metadata

Assignees

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions