Currently, i am setting the livekit logs to logfir...
# ask-ai
f
Currently, i am setting the livekit logs to logfire, by doing
Copy code
provider = trace.get_tracer_provider()
set_tracer_provider(provider)
It successfully moves the logs to logfire, but the issue now is that I can't have control of how livekit is logging it. Livekit logs each conversation history as a span, where there is system message, user message and assistant message, which would pile up as the conversation prolongs. Is there a way for us to configure what gets sent? or perhaps able to set which as debug level and which at info level?
t
Thanks for reaching out, Mok. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
LiveKit logging levels and log content can’t be configured through a custom tracer provider. The tracer provider only impacts OpenTelemetry trace data, not the application's logging system. Could you please help me understand a bit more about what you're aiming for? Are you looking to enrich trace data (for example, using set_tracer_provider with metadata), or are you hoping to control the log output itself (like setting log levels or filtering log messages)? Knowing this will really help me guide you in the right direction. Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/log.py | Logs, metrics, and telemetry | LiveKit Docs | Log collection | LiveKit Docs | How to Send Logs from the JavaScript SDK to Providers like Datadog | web/e2ee.logger.dart
f
I wish to control the log output itself, such as setting log levels or filtering certain log messages
t
To help you manage log output in LiveKit, you can easily adjust log levels or filter log messages based on the SDK or environment you're working with. Let’s walk through the options together: 1. Client SDKs: • JavaScript/TypeScript: You can use
setLogLevel
to choose levels like
debug
,
info
, or
error
. Here’s a simple example:
Copy code
import { setLogLevel, LogLevel } from 'livekit-client';
setLogLevel(LogLevel.debug);
• React Native: Works similarly to JavaScript, and you have the flexibility to set different levels for
@livekit/react-native
and
@livekit-client
. • Flutter: Just use
setLoggingLevel
with options like
kINFO
or
kSEVERE
. • Android: You can set
LiveKit.loggingLevel
to
DEBUG
,
INFO
, and so on. 2. Custom Logging: • If you want to send logs to external services like Sentry or Datadog, try using
setLogExtension
(JavaScript). 3. Server/Agent Logs: • Within your Dockerfile, you can set log levels using
--log-level=DEBUG
. • To forward logs to Datadog, just set the
DATADOG_TOKEN
secret. If you’d like, I’m here to provide specific examples or walk you through any part of your setup. Just let me know! Sources: src/logger.ts | docs/types/SetLogLevelOptions.html | web/e2ee.logger.dart | livekit-android-sdk/src/main/java/io/livekit/android/util/LKLog.kt | packages/core/src/logger.ts
f
erm, i meant for livekit, can i configure which to set as info and which to set as debug for livekit default logs?
t
LiveKit doesn’t support configuring individual log messages to be labeled as "info" or "debug" just yet. But don’t worry! You can control the overall verbosity by setting global or module-specific log levels. Here’s how you can do it: • In the JavaScript SDK, you can use
setLogLevel
to set levels like
debug
or
info
either globally or for specific parts like
Room
or
Participant
. • For server-side components, you can adjust the log level using command-line flags (like
--log-level=DEBUG
) or through configuration files. If you’re looking for more detailed control, setLogExtension lets you intercept logs and send them to external services where you can filter or categorize them however you need. Feel free to reach out if you’d like a hand setting this up—I’m here to help! Sources: Sources/LiveKit/Broadcast/Support/OSLogHandler.swift | Worker options | LiveKit Docs | config-sample.yaml | src/logger.ts | docs/functions/setLogLevel.html