Skip to content

feat: Add experimental structured logging with --json and --log-file flags#12405

Merged
anthonyshew merged 1 commit intomainfrom
shew/structured-logging
Mar 20, 2026
Merged

feat: Add experimental structured logging with --json and --log-file flags#12405
anthonyshew merged 1 commit intomainfrom
shew/structured-logging

Conversation

@anthonyshew
Copy link
Contributor

Summary

  • Adds --json flag to stream NDJSON to stdout and --log-file [path] flag to write structured JSON logs to a file, both behind an experimental marker
  • Supports TURBO_LOG_FILE environment variable as an alternative to the CLI flag
  • Deliberately omits logFile from turbo.json — structured logging is a per-invocation concern better suited to CLI flags and env vars than checked-in config

How to test

# NDJSON to stdout
turbo run build --json 2>/dev/null | head -5

# File output (default path)
turbo run build --log-file
cat .turbo/logs/*.json | python3 -m json.tool | head -20

# File output (custom path)
turbo run build --log-file=my-log.json

# Env var
TURBO_LOG_FILE=1 turbo run build

# Both modes simultaneously
turbo run build --json --log-file=build.json

Each JSON entry has timestamp, source, level, and text fields. ANSI escape sequences are stripped in file output.

@anthonyshew anthonyshew requested a review from a team as a code owner March 20, 2026 19:47
@anthonyshew anthonyshew requested review from tknickman and removed request for a team March 20, 2026 19:47
@vercel
Copy link
Contributor

vercel bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
turbo-site Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Mar 20, 2026 7:59pm

@anthonyshew anthonyshew changed the title feat: Add experimental structured logging with --json and --log-file flags feat: Add experimental structured logging with --json and --log-file flags Mar 20, 2026
@anthonyshew anthonyshew force-pushed the shew/structured-logging branch from c4c9763 to b810b07 Compare March 20, 2026 19:52
…flags

Add machine-readable JSON output for turbo run via two new CLI flags:

- --json: Stream NDJSON to stdout (disables TUI, forces stream mode)
- --log-file [path]: Write structured JSON array to a file

Also supported via TURBO_LOG_FILE environment variable.

Includes documentation in the run command reference and system
environment variables pages, marked as experimental.
@anthonyshew anthonyshew force-pushed the shew/structured-logging branch from b810b07 to 52dbe36 Compare March 20, 2026 19:58
@anthonyshew anthonyshew merged commit 7ca0601 into main Mar 20, 2026
57 checks passed
@anthonyshew anthonyshew deleted the shew/structured-logging branch March 20, 2026 20:07
github-actions bot added a commit that referenced this pull request Mar 20, 2026
## Release v2.8.21-canary.2

Versioned docs: https://v2-8-21-canary-2.turborepo.dev

### Changes

- fix: Strip JSX components from heading anchors and TOC entries
(#12404) (`3abe553`)
- fix: Move docs app icons into app/ directory (#12403) (`ddf3918`)
- feat: Add experimental structured logging with `--json` and
`--log-file` flags (#12405) (`7ca0601`)
- release(turborepo): 2.8.21-canary.1 (#12407) (`adebb95`)
- docs: Downgrade Next.js (#12408) (`281e89b`)
- chore: Deprecate the `turbo scan` command (#12406) (`4a12c26`)

Co-authored-by: Turbobot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant