LogLevel setting with CBL DB18 Info producing more detailed log than Verbose?

Hello All,

After integrating CBL db18, we have made the following code changes to set the LogLevel properly.

CBL db16:
Couchbase.Lite.Logging.Log.Domains.Database.Level = Couchbase.Lite.Logging.LogLevel.Verbose;

CBL db18:
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Database, Couchbase.Lite.Logging.LogLevel.Verbose)

And, noticing that setting the LogLevel to “Info” to available domains(reduced in CBL db 17 and 18)
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Database, /Couchbase.Lite.Logging.LogLevel.Info) ;
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Query, /Couchbase.Lite.Logging.LogLevel.Info;
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.LiteCore, /Couchbase.Lite.Logging.LogLevel.Info);
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Replicator, /Couchbase.Lite.Logging.LogLevel.Info);

producing more detailed information than setting LogLevel to “Verbose”

Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Database, Couchbase.Lite.Logging.LogLevel.Verbose) ;
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Query, Couchbase.Lite.Logging.LogLevel.Verbose);
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.LiteCore, Couchbase.Lite.Logging.LogLevel.Verbose);
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.Replicator, Couchbase.Lite.Logging.LogLevel.Verbose);

Can you please verify if this is how it is intended to work?

Also,does the order in the LogLevel enum means anything like 0/Debug is most informative then 1/Verbose? Or, order doesn’t mean anything rather the intend/name is more accurate reflection of the logging purpose?

Isn’t Verbose suppose to capture all “Info, Error, Warning, Verbose” ?

Also, we are also internally using MS Logging, trying to map it to CBL’s LogLevel


Assuming mapping MS’s Trace and Critical to CBL’s Verbose, and Error would be appropriate?

Thank you

That’s how it is supposed to work, if it’s not then it needs to be fixed. The API change was just to bring it inline with Java and Swift, but underneath that it is still making the same calls. The other thing that changed is that by default a binary file will be created, and text logging will be optional (by a call to EnableTextLogging inside of the Support class assembly).

Debug will only function in debug builds (which are not on the Nuget feed, and are for internal use). Verbose is the highest and should output everything under it (Info, Warning, Error), and so on (Info also includes Warning, Error).

Thanks.

Setting LogLevel to "Info"
Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.All, /Couchbase.Lite.Logging.LogLevel.Info);

produces all these CBL log messages

{“Timestamp”:“2017-11-08T09:59:57.3629359-08:00”,“Level”:“Information”,“MessageTemplate”:"(XQuery) [6] 2017-11-08T09:59:57.3629359-08:00 Query encoded as {“WHAT”:[["._id"]]}",“Properties”:{“SourceContext”:“QUERY”,“ContextProperties”:{}}}
{“Timestamp”:“2017-11-08T09:59:57.3669258-08:00”,“Level”:“Information”,“MessageTemplate”:“Compiling JSON query: {“WHAT”:[[”._id"]]}",“Properties”:{“SourceContext”:“LITECORE”,“ContextProperties”:{}}}
{“Timestamp”:“2017-11-08T09:59:57.3696578-08:00”,“Level”:“Information”,“MessageTemplate”:“Compiled Query: SELECT sequence, key, version, flags, key FROM kv_default WHERE (flags & 1) = 0”,“Properties”:{“SourceContext”:“LITECORE”,“ContextProperties”:{}}}
{“Timestamp”:“2017-11-08T09:59:57.3736606-08:00”,“Level”:“Information”,“MessageTemplate”:“Created prerecorded query enum with 0 rows (2 bytes) in 0.011ms”,“Properties”:{“SourceContext”:“LITECORE”,“ContextProperties”:{}}}
{“Timestamp”:“2017-11-08T09:59:57.3766631-08:00”,“Level”:“Information”,“MessageTemplate”:"(QueryResultSet) [6] 2017-11-08T09:59:57.3766631-08:00 Beginning query enumeration (f371af0)",“Properties”:{“SourceContext”:“QUERY”,“ContextProperties”:{}}}

where as setting LogLevel “Verbose” doesn’t produce any of those messages.

Database.SetLogLevel(Couchbase.Lite.Logging.LogDomain.All, /Couchbase.Lite.Logging.LogLevel.Verbose);

As per your response, “Verbose” should also include messages like all of these. Can you please check?

I believe, CBL 16 and prior used to use Microsoft.Extensions.Logging


Looks like CBL db17 and 18 have their own LogLevel enum now. May be the recent code changes around logging is still mapping to old Microsoft Logging order?

Also noticed CBL db18, seems like not producing messages like (Startup) any more.

“Level”:“Information”,“MessageTemplate”:"(Startup) [3] 2017-11-08T13:22:06.3619446-08:00 CouchbaseLite/2.0.0-b0322 (.NET; UWP 10.0.10586.318; Dell Inc. OptiPlex 9020) Build/0 Commit/7548fae\r\n",“Properties”:{“SourceContext”:“Default”,“ContextProperties”:{}}}

Yes the logging API was refactored to make the API consistent between Java, Swift, and C#. Also one more thing is that the logging now goes entirely through LiteCore, so I will look into why it doesn’t behave as it should.

Looks like all this back and forth about whether log levels should include levels greater than or less than them has caused an incorrect logical comparison. If I switch a simple >= to <= things start working as they should…

Filed this and will close it once I get some other things under control. On a related note, we will also be taking a closer look at the logging API in general in the next week or so.

Thanks so much borrrden