Skip to content

Commit b7391ed

Browse files
Add logging configuration to Sandbox SDK docs (cloudflare#26635)
Document SANDBOX_LOG_LEVEL and SANDBOX_LOG_FORMAT environment variables for controlling SDK logging behavior.
1 parent 56610bd commit b7391ed

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/content/docs/sandbox/configuration/sandbox-options.mdx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 4
66
---
77

8-
import { TypeScriptExample } from "~/components";
8+
import { TypeScriptExample, WranglerConfig } from "~/components";
99

1010
Configure sandbox behavior by passing options when creating a sandbox instance with `getSandbox()`.
1111

@@ -108,6 +108,30 @@ const sandbox2 = getSandbox(env.Sandbox, 'user-env', {
108108

109109
Precedence: `options` > `env vars` > SDK defaults
110110

111+
### Logging
112+
113+
**Type**: Environment variables
114+
115+
Control SDK logging for debugging and monitoring. Set these in your Worker's `wrangler.jsonc` file.
116+
117+
**Available options**:
118+
- `SANDBOX_LOG_LEVEL` - Minimum log level: `debug`, `info`, `warn`, `error`. **Default**: `info`
119+
- `SANDBOX_LOG_FORMAT` - Output format: `json`, `pretty`. **Default**: `json`
120+
121+
<WranglerConfig>
122+
```toml
123+
[vars]
124+
SANDBOX_LOG_LEVEL = "debug"
125+
SANDBOX_LOG_FORMAT = "pretty"
126+
```
127+
</WranglerConfig>
128+
129+
:::note[Read at startup]
130+
Logging configuration is read when your Worker starts and cannot be changed at runtime. Changes require redeploying your Worker.
131+
:::
132+
133+
Use `debug` + `pretty` for local development. Use `info` or `warn` + `json` for production (structured logging).
134+
111135
### normalizeId
112136

113137
**Type**: `boolean`

0 commit comments

Comments
 (0)