couchbase-lite-java-ce-root icon indicating copy to clipboard operation
couchbase-lite-java-ce-root copied to clipboard

Warning written to log on every Database open regardless of status of File Log Sinks

Open andrew-charles opened this issue 6 months ago • 1 comments

Every time I open a database, I get this log message, no matter what I have set for File based logging:

W Database.log.getFile().getConfig() is now null: logging is disabled. Log files required for product support are not being generated.

This message is outright wrong in this case, as it's not null, but apparently there's a bug in the code and no matter what you'll get this message:

private void warnIfNoFileLogSink() {
        final FileLogSink sink = fileLogSink;
        if ((sink != null) && (sink.getLevel() != LogLevel.NONE) && !warned.getAndSet(true)) { return; }
        ((AbstractLogSink) new ConsoleLogSink(LogLevel.WARNING, LogDomain.DATABASE)).writeLog(
            LogLevel.WARNING,
            LogDomain.DATABASE,
            "Database.log.getFile().getConfig() is now null: logging is disabled.  "
                + "Log files required for product support are not being generated.");
    }

I have several issues with this code besides this.

  1. If I want to disable File based logging, I should be able to do it, and not get complaints about it. If there has to be a warning, it should be on init(), not every single time I attempt to open a DB. The older version of couchbase lite mobile (2.x) did not have this issue.
  2. This code here creates an arbitrary console logger (which in android writes to Logcat), so there's no way to suppress it.

andrew-charles avatar Apr 29 '25 16:04 andrew-charles