A newer version of this documentation is available.

View Latest

Collecting Information and Logging in the Go SDK with Couchbase Server

The Go SDK offers simple logging of library internals to help debug issues. Logging may be configured on a global library-level basis. Note that the logging API is subject to change.

You can configure logging using the gocbcore.SetLogger, which accepts an implementation of gocbcore.Logger. The SDK comes with two built-in Logger implementations, which can be instantiated using the following methods:

  • gocbcore.DefaultStdioLogger() returns a logger that logs errors and warnings. This is fairly non-disruptive and does not produce a lot of output

  • gocbcore.VerboseStdioLogger() returns a logger that logs more detailed tracing information. This logger should only be used when trying to diagnose an issue.

import (
        "github.com/couchbaselabs/gocb/gocbcore"
)

func main() {
        gocbcore.SetLogger(gocbcore.DefaultStdioLogger())

        // Use the gocb library.
}