---
title: "In zsh, `log` is a shell builtin that silently shadows macOS's /usr/bin/log"
url: "https://www.dariuszparys.com/notes/zsh-log-builtin-shadows-macos-log"
author: "Dariusz Parys"
published: 2026-11-25T00:00:00.000Z
description: "Unified-log queries run as log show in zsh returned nothing, because zsh's own log builtin took the command and its error was discarded with 2>/dev/null."
tags:
  - "Shell"
---

# In zsh, `log` is a shell builtin that silently shadows macOS's /usr/bin/log

## Context

I was looking for the cause of stutter in a macOS game and ran several unified-log searches from zsh: GPU faults, display events, and a background `log stream` capture. They all came back empty, and I wrongly read that as "no matching entries".

## The insight

zsh has its own builtin called `log`, which comes from its watch/who feature. So in zsh, `log show --predicate …` never reaches Apple's log tool. The builtin fails with `log: too many arguments`, and `2>/dev/null` hides that error, so a failed query looks exactly like an empty result.

The query only worked when another command came first, as in `timeout 60 log show …`, because that command runs the real binary.

- In zsh scripts, call `/usr/bin/log` or `command log`.
- Don't discard stderr on a query whose empty result you will treat as evidence.

```zsh
/usr/bin/log show --last 10m --predicate 'subsystem == "com.apple.Metal"'
command log stream --level debug
```

## Second trap: `log stream` output is buffered

`log stream > file &` writes to the file in blocks, so killing it loses whatever is still buffered. Read the window back afterwards instead:

```zsh
/usr/bin/log show --start '2026-01-01 10:00:00' --end '2026-01-01 10:05:00' --predicate '…'
```

## Related trick: the Metal HUD in the unified log

```zsh
launchctl setenv MTL_HUD_ENABLED 1
launchctl setenv MTL_HUD_LOG_ENABLED 1
```

Metal apps launched after this write a `metal-HUD:` line every second and `Metal Compiling Shader` events to the unified log.
