lemon-alligator-22437
10/13/2025, 2:21 PMlk agent logs command? I always get scanner error: bufio.Scanner: token too longtall-airline-16756
10/13/2025, 2:21 PMtall-airline-16756
10/13/2025, 2:22 PMlk agent logs command. It uses Go's bufio.Scanner, which has a default token size limit. So, if a log line goes beyond this limit (usually around 64KB), you might see the error scanner error: bufio.Scanner: token too long. I know that can be a bit frustrating!
Right now, there isn’t a way to adjust this buffer size through runtime settings or CLI flags. But don’t worry—you can actually tweak the LiveKit CLI source code to increase this limit. In the StreamLogs function, adding the following snippet will help you set a custom buffer size:
scanner := bufio.NewScanner(resp.Body)
const maxLogLineSize = 1 << 20 // 1 MB
buffer := make([]byte, maxLogLineSize)
scanner.Buffer(buffer, maxLogLineSize)
Once you’ve done that, just rebuild the CLI tool, and you should be good to go!
If changing the source code isn’t something you want to dive into, another approach is to truncate or split those really long log messages before they get to lk agent logs. You might also find it helpful to use tools like Fluentd or Logstash to pre-process your logs—they can work wonders in managing log sizes.
Please feel free to reach out if you’d like any help walking through these steps or if you have other questions. I’m here to support you!
Sources: autocomplete/fish_autocomplete