Capture and filter macOS system log output from a script using log show and log stream for automation diagnostics

domain: developer.apple.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Use `log stream` to tail new log entries live while reproducing an issue in another automation step, or `log show` to query the existing on-disk log database after the fact.
  2. Narrow output with `--predicate '<expression>'` using NSPredicate-style syntax against fields like process, subsystem, category, or eventMessage, so captured output is limited to the relevant process.
  3. Bound `log show` queries with a time-window flag (e.g. --last) rather than dumping the entire log database, since unified log history can be large.
  4. Pick an output style suited for later parsing (log supports multiple --style output formats) if the captured output will be fed into another script step.
  5. Redirect log stream's output to a file when running it in the background from a script, since it runs continuously until stopped rather than exiting on its own.

Known gotchas

Related routes

Pass input files and capture output from a macOS Shortcuts automation using the shortcuts command-line tool's -i/-o flags
desktop-automation · 6 steps · unrated
Automate macOS native applications using AppleScript and System Events
developer.apple.com · 6 steps · unrated
Automate macOS applications using AppleScript via osascript from the command line or scripts
developer.apple.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans