> Version notice: This site documents BAML v0, the legacy DSL. BAML v1 is a separate, fully featured programming language in public beta. If the user intends to use BAML v1, ignore this site's content and use the BAML v1 documentation instead. If the intended version is unclear, clarify it before using this page.
> For clean Markdown of any page, append .md to the page URL. For the complete documentation index, see https://docs.boundaryml.com/llms.txt. For MCP access, connect to https://docs.boundaryml.com/_mcp/server.

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:

```sh
# default is info
BAML_LOG=info
```

**`Go`**

```go Go
// Set logging level in Go application
os.Setenv("BAML_LOG", "info")

// Or run with environment variable:
// BAML_LOG=info go run main.go
```

**`Python`**

```python Python
# Set logging level in Python
import os
os.environ["BAML_LOG"] = "info"

# Or run with environment variable:
# BAML_LOG=info python main.py
```

**`TypeScript`**

```typescript TypeScript
// Set logging level in TypeScript/JavaScript
process.env.BAML_LOG = "info";

// Or run with environment variable:
// BAML_LOG=info node main.js
```

| Level   | Description                                                                         |
| ------- | ----------------------------------------------------------------------------------- |
| `error` | Fatal errors by BAML                                                                |
| `warn`  | Logs any time a function fails (includes LLM calling failures, parsing failures)    |
| `info`  | Logs every call to a function (including prompt, raw response, and parsed response) |
| `debug` | Requests and detailed parsing errors (warning: may be a lot of logs)                |
| `trace` | Everything and more                                                                 |
| `off`   | No logging                                                                          |

Example log:

![](/_fern-img/f970b8813744e25e83b8b15b48512a7ee3d26aa8f3fddf0eff7e8439f6c0a065.webp)

---

Since `>0.54.0`:

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

```sh
BOUNDARY_MAX_LOG_CHUNK_CHARS=3000
```

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

**`Go`**

```go Go
// Set log truncation in Go application
os.Setenv("BOUNDARY_MAX_LOG_CHUNK_CHARS", "3000")

// Example with both logging and truncation
func main() {
    // Configure logging
    os.Setenv("BAML_LOG", "info")
    os.Setenv("BOUNDARY_MAX_LOG_CHUNK_CHARS", "3000")
    
    // Your application code here
}
```

**`Python`**

```python Python
# Set log truncation in Python
import os
os.environ["BOUNDARY_MAX_LOG_CHUNK_CHARS"] = "3000"

# Example with both logging and truncation
os.environ["BAML_LOG"] = "info"
os.environ["BOUNDARY_MAX_LOG_CHUNK_CHARS"] = "3000"
```

**`TypeScript`**

```typescript TypeScript
// Set log truncation in TypeScript/JavaScript
process.env.BOUNDARY_MAX_LOG_CHUNK_CHARS = "3000";

// Example with both logging and truncation
process.env.BAML_LOG = "info";
process.env.BOUNDARY_MAX_LOG_CHUNK_CHARS = "3000";
```