> ## Documentation Index
> Fetch the complete documentation index at: https://sourcebot-whoisthey-pin-citation-commit-sha.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured Logging

By default, Sourcebot will output logs to the console in a human readable format. If you'd like Sourcebot to output structured JSON logs, set the following env vars:

* `SOURCEBOT_STRUCTURED_LOGGING_ENABLED` (default: `false`): Controls whether logs are in a structured JSON format
* `SOURCEBOT_STRUCTURED_LOGGING_FILE`: If structured logging is enabled and this env var is set, structured logs will be written to this file (ex. `/data/sourcebot.log`)

### Structured log schema

```json theme={null}
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "SourcebotLog",
    "properties": {
        "level": {
            "type": "string",
            "description": "The log level (error, warning, info, debug)"
        },
        "service": {
            "type": "string",
            "description": "The Sourcebot component that generated the log"
        },
        "message": {
            "type": "string",
            "description": "The log message"
        },
        "status": {
            "type": "string",
            "description": "The same value as the level field added for datadog support"
        },
        "timestamp": {
            "type": "string",
            "description": "The timestamp of the log in ISO 8061 format"
        }
    }
}
```
