Skip to main content


A logging interface is provided to handle log messages generated by the client. Most log messages are generated from background cluster tend thread(s) created for each client instance. Messages include node additions/removal and any errors when retrieving node status, peers, partition maps and racks. This information is critical to debug transaction failures resulting from cluster tend errors.

Enable Client Log

The log is global so it only needs to enabled once at application launch before calling aerospike_connect(). Here is an example that enables the client log and prints the messages to stdout.

#include <time.h>
#include <stdbool.h>
#include <stdio.h>
#include <aerospike/as_log.h>

static bool my_log_callback(
as_log_level level, const char* func, const char* file, uint32_t line,
const char* fmt, ...)
char fmtbuf[1024];
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
struct tm* t = localtime(&now.tv_sec);
uint64_t msecs = now.tv_nsec / 1000000;

va_list ap;
va_start(ap, fmt);

snprintf(fmtbuf, sizeof(fmtbuf), "%d-%02d-%02d %02d:%02d:%02d.%03" PRIu64 " %s %s\n",
t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min,
t->tm_sec, msecs, as_log_level_tostring(level), fmt);

vprintf(fmtbuf, ap);
return true;

int main(int argc, char* argv[])

Disable Client Log

The client log can be disabled by setting the log callback to NULL.


Log Level

Client log messages can be filtered by log level.

  • AS_LOG_LEVEL_ERROR Serious errors that require immediate attention.

  • AS_LOG_LEVEL_WARN Warnings regarding cluster tend errors that might lead to transaction failures.

  • AS_LOG_LEVEL_INFO Informational cluster changes including adding a node and removing a node from the cluster.

  • AS_LOG_LEVEL_DEBUG Extra debug data.

  • AS_LOG_LEVEL_TRACE Even more debug data. Not recommended.

Each level includes the levels above it, so INFO includes INFO, WARN and ERROR messages. Example: