Terminal Logs

You can add logging to determine what the BAML runtime is doing when it calls LLM endpoints and parses responses.

To enable logging, set the BAML_LOG environment variable:

1# default is info
2BAML_LOG=info
1// Set logging level in Go application
2os.Setenv("BAML_LOG", "info")
3
4// Or run with environment variable:
5// BAML_LOG=info go run main.go
LevelDescription
errorFatal errors by BAML
warnLogs any time a function fails (includes LLM calling failures, parsing failures)
infoLogs every call to a function (including prompt, raw response, and parsed response)
debugRequests and detailed parsing errors (warning: may be a lot of logs)
traceEverything and more
offNo logging

Example log:


Since >0.54.0:

To truncate each log entry to a certain length, set the BOUNDARY_MAX_LOG_CHUNK_CHARS environment variable:

1BOUNDARY_MAX_LOG_CHUNK_CHARS=3000

This will truncate each part in a log entry to 3000 characters.

1// Set log truncation in Go application
2os.Setenv("BOUNDARY_MAX_LOG_CHUNK_CHARS", "3000")
3
4// Example with both logging and truncation
5func main() {
6 // Configure logging
7 os.Setenv("BAML_LOG", "info")
8 os.Setenv("BOUNDARY_MAX_LOG_CHUNK_CHARS", "3000")
9
10 // Your application code here
11}