Setting up logging

The library offers basic functionality for logging to the program's standard error stream. The most common way to enable logging is to set the LCB_LOGLEVEL environment variable to a number between 1 and 5, with 5 being the most verbose and 1 being the least verbose. Logging can also be enabled programmatically via the LCB_CNTL_CONLOGGER_LEVEL setting or the console_log_level option in the connection string. There is also support for receiving a logging callback (via LCB_CNTL_LOGGER).

The logging output should be considered a work in progress, but does yield important information on what the library is doing and any errors being encountered.

Understanding output

The console logger outputs a line that looks similar to this:
1ms [I0] {14780} [DEBUG] (lcbio_mgr - L:383) <localhost:11210> (HE=0xe56760) 
Creating new connection because none are available in the pool

The following table describes the components of the log entries:

Format Description
nms The number of milliseconds elapsed since the loading of the library
[In] The identifier of the lcb_t object associated with the current message. This allows you to determine the origin of the message in the case where the application contains multiple such lcb_t objects. The number is incremented for each call to lcb_create()
{PID} The current thread ID. On Linux this is also the process ID for single-threaded programs, further helping distinguish between multiple forks of an application.
[LEVEL] A string representing the severity of the level
(subsystem - L:line) The subsystem that produced this message, followed by the source code line at which this message was created. The subsystem will typically, but not always, resemble the source code file. It is a small string describing what the current line is doing.
<host:port> The host and port, if any, associated with the message. This is supplied for messages that relate to the state of a particular connection.