Skip to main content

Privacy and console logs

note

Looking for the previous SDK? See the 6.x log privacy page.

Disabling log collection

Log collection can be turned off with the CaptureLogs option — see configuration.

Sanitizing logs

7.0 uses a single generic filter interface, EventFilter<T>, for both log and network events. Its single filter(log, callback) method hands you the event and a Callback1 to invoke with the result: call callback.run(log) to keep the (possibly mutated) event, or callback.run(null) to drop it entirely. The filter method is synchronous.

The event type is LogEvent (package com.bugsee.library.contracts.exchange).

Bugsee.setLogEventFilter((log, callback) -> {
String message = log.getMessage();
if (message != null) {
// Strip tokens, redact PII, etc.
log.setMessage(message.replaceAll("token=\\S+", "token=[REDACTED]"));
}

// Pass the mutated event to keep it…
callback.run(log);

// …or call callback.run(null) to drop it entirely:
// callback.run(null);
});
setLogFilter alias

Bugsee.setLogFilter(EventFilter<LogEvent>) is a deprecated alias for setLogEventFilter(...). Both resolve to the same registration.

Declaring the filter in the manifest

You can also point Bugsee at a log filter from AndroidManifest.xml, with no code. Add a com.bugsee.filter.log-event <meta-data> whose value is a class that implements EventFilter<LogEvent> and has a public no-arg constructor. The benefit: the filter is in force from the very first captured event, even under auto-initialization, before any of your own code runs.

<application>
<meta-data android:name="com.bugsee.filter.log-event"
android:value="com.example.MyLogFilter" />
</application>
import androidx.annotation.Keep;
import com.bugsee.library.contracts.common.Callback1;
import com.bugsee.library.contracts.exchange.EventFilter;
import com.bugsee.library.contracts.exchange.LogEvent;

@Keep // referenced only by name in the manifest — keep it from R8
public class MyLogFilter implements EventFilter<LogEvent> {
public MyLogFilter() { } // required public no-arg constructor

@Override
public void filter(LogEvent log, Callback1<LogEvent> callback) {
String message = log.getMessage();
if (message != null) {
log.setMessage(message.replaceAll("token=\\S+", "token=[REDACTED]"));
}
callback.run(log); // pass null to drop
}
}

A filter set in code with Bugsee.setLogEventFilter(...) takes precedence over the manifest one. Because the class is referenced only by name, keep it from R8 — annotate it @Keep or add -keep class com.example.MyLogFilter { <init>(); }.

The same mechanism is available for network events and breadcrumbs.

Found an issue, typo, or wrong statement on this page? Report it now →