is there a logging level env var for livekit? or h...
# ask-ai
b
is there a logging level env var for livekit? or how to set it up?
t
Thanks for reaching out, mateuszkasprowicz. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! I want to help you get the logging levels set up just right. LiveKit doesn’t have one universal environment variable for logging levels across all its components, so it depends a bit on which part you’re working with: • LiveKit Server: You can set the
log_level
in the configuration file (YAML) or by using the
LIVEKIT_CONFIG
environment variable. The options you can choose from are
debug
,
info
,
warn
,
error
, and
critical
. • AI Agents: When you start the agent, just add the
--log-level
flag (for example,
--log-level=DEBUG
), and you’re good to go. • Client SDKs: You’ll want to set logging programmatically using SDK-specific methods like
setLogLevel()
. This works for React Native, Android, Swift, or JavaScript. If you’re focusing on a particular component or need a hand with something specific, please feel free to let me know! I’m here to guide you through it. Sources: How to Send Logs from the JavaScript SDK to Providers like Datadog | Deploying LiveKit | LiveKit docs | Worker options | LiveKit Docs | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/log.py | livekit-android-sdk/src/main/java/io/livekit/android/LiveKit.kt
b
• AI Agents: When you start the agent, just add the
--log-level
flag (for example,
--log-level=DEBUG
), and you’re good to go. can this be defined in the code somewhere not only with the CLI command arg?
t
Absolutely! You can definitely set the log level for LiveKit AI Agents directly in your code instead of relying on the
--log-level
CLI argument. A great way to do this is by using Python's built-in
logging
module. Here's a simple example to get you started:
Copy code
import logging

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Also, the
setup_logging
function within the LiveKit agents' codebase is super handy—it lets you programmatically set both the root and agent logger levels using a
log_level
string input. If you'd like, I'm here to help you walk through the implementation or answer any questions you might have! Sources: Building an Automated IVR Menu Caller | LiveKit Docs | stream_audio.py | livekit-plugins/livekit-plugins-upliftai/livekit/plugins/upliftai/log.py | Log collection | LiveKit Docs | Worker options | LiveKit Docs