Logging

June 17, 2026 · View on GitHub

The SDK uses spdlog internally but does not expose it in public headers. All log output goes through a thin public API in <livekit/logging.h>.

Two-tier filtering

TierWhenHowCost
Compile-timeCMake configure-DLIVEKIT_LOG_LEVEL=WARNZero — calls below the level are stripped from the binary
RuntimeAny time after initialize()livekit::setLogLevel(LogLevel::Warn)Minimal — a level check before formatting

Compile-time level (LIVEKIT_LOG_LEVEL)

Set once when you configure CMake. Calls below this threshold are completely removed by the preprocessor — no format-string evaluation, no function call.

# Development (default): keep everything available
cmake -DLIVEKIT_LOG_LEVEL=TRACE ..

# Release: strip TRACE / DEBUG / INFO
cmake -DLIVEKIT_LOG_LEVEL=WARN ..

# Production: only ERROR and CRITICAL survive
cmake -DLIVEKIT_LOG_LEVEL=ERROR ..

Valid values: TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF.

Runtime level (setLogLevel)

Among the levels that survived compilation you can still filter at runtime without rebuilding:

#include <livekit/livekit.h>

livekit::initialize();                           // default level: Info
livekit::setLogLevel(livekit::LogLevel::Debug);  // show more detail
livekit::setLogLevel(livekit::LogLevel::Warn);   // suppress info chatter

Custom log callback

Replace the default stderr sink with your own handler. This is the integration point for frameworks like ROS2 (RCLCPP_* macros), Android logcat, or any structured-logging pipeline:

#include <livekit/livekit.h>

livekit::initialize();
livekit::setLogLevel(livekit::LogLevel::Trace);

livekit::setLogCallback(
    [](livekit::LogLevel level,
       const std::string &logger_name,
       const std::string &message) {
      // Route to your framework, e.g.:
      //   RCLCPP_INFO(get_logger(), "[%s] %s", logger_name.c_str(), message.c_str());
      myLogger.log(level, logger_name, message);
    });

// Pass nullptr to restore the default stderr sink:
livekit::setLogCallback(nullptr);

See the logging_levels/custom_sinks example for three copy-paste-ready patterns: a file logger, JSON structured lines, and a ROS2 bridge that maps LogLevel to RCLCPP_* macros.

Available log levels

LevelTypical use
TracePer-frame / per-packet detail (very noisy)
DebugDiagnostic info useful during development
InfoNormal operational messages (connection, track events)
WarnUnexpected but recoverable situations
ErrorFailures that affect functionality
CriticalUnrecoverable errors
OffSuppress all output