skip to content

With iOS unified logging, how does support pull a renter's iPhone logs onto a Mac and filter them to the app, and what can an in-app OSLogStore export see?

level: seniorimportance: should knowfreq 30%

answer

  1. an archive, not a text file
  2. collect from the paired device
  3. predicate on subsystem and category
  4. show hides info and debug
  5. the store's scope on iOS

basics

~10 s

Run log collect --device on a Mac to get a .logarchive, then filter it in Console or log show by subsystem and category. In the app, OSLogStore(scope: .currentProcessIdentifier) reads only the current process's entries.

solid answer

~40 s

With the phone connected and paired, `log collect --device --last 2h --output checkin.logarchive` pulls the device's logs into an archive. Open it in Console or run `log show --archive` with `--predicate 'subsystem == "com.example.boatrental" && category == "dock-checkin"'`; add `--info`/`--debug` because `log show` prints only default-level lines otherwise. Expect gaps: debug is never persisted, info only when the log tool collects it, old entries are purged, and redacted strings stay `<private>`. In the app, `OSLogStore(scope: .currentProcessIdentifier)` (iOS 15) with `getEntries(with:at:matching:)` reads entries this running process wrote; `.system` and `local()` are unavailable on iOS, so a report must be exported before the app relaunches.

code

bash · 6 lines
bash
# On the Mac, with the renter's iPhone connected and paired
log collect --device --last 2h --output ~/Desktop/checkin.logarchive

# Only the app's check-in lines, including any info and debug lines captured
log show --archive ~/Desktop/checkin.logarchive --info --debug \
  --predicate 'subsystem == "com.example.boatrental" && category == "dock-checkin"'

go deeper

for a junior

Recall that device logs are read on a Mac with Console or the log tool, not as a text file on the phone.

for a middle

Explain log collect's device, time and output options, log show's predicate on subsystem and category, and why --info and --debug matter.

for a senior

Plan for gaps: unpersisted debug and info, purged old entries, redacted values, and OSLogStore's current-process limit when choosing a route.

for a principal

Decide what the support path is for field failures, an in-app export or a Mac collection, and what it forces into notice-level logging.

## Two routes to a renter's logs When a dock check-in fails only for some renters, support needs the lines the app wrote on that phone. Unified logging offers two routes: - **From a Mac**: connect the phone and pull a log archive with the `log` command-line tool, then read it in Console or with `log show`. - **From inside the app**: read the app's own entries with the OSLog framework's `OSLogStore` and attach them to a support report. ## Pulling an archive with `log collect` `log collect` gathers the system logs into a `.logarchive` bundle. The options that matter for a phone: - `--device` collects from the first paired device found; `--device-name` and `--device-udid` pick a specific one. - `--last 2h` or `--start "2026-10-26 09:00:00"` limit the time range; `--size 20m` approximately caps the amount. - `--output` sets the path; without it, `system_logs.logarchive` is created in the current directory. - `--predicate` filters during collection, but the tool warns it can significantly increase the time and memory needed, so filter afterwards instead. ```bash # On the Mac, with the renter's iPhone connected and paired log collect --device --last 2h --output ~/Desktop/checkin.logarchive # Only the app's check-in lines, including any info and debug lines captured log show --archive ~/Desktop/checkin.logarchive --info --debug \ --predicate 'subsystem == "com.example.boatrental" && category == "dock-checkin"' ``` ## Reading the archive Open the `.logarchive` in the Console app, or use `log show --archive`. Filter with an NSPredicate on `subsystem` and `category`; the man page advises giving the subsystem whenever you filter by category. `log show` prints only default-level messages unless you add `--info` and/or `--debug`, and signposts only with `--signpost`. `log stream` follows live events on the Mac it runs on and has no device option, so for a phone the archive is the tool. ## What the archive can and cannot contain 1. **Lines below notice may be missing.** Apple's level table says debug is never persisted and info only when collected with the `log` tool, so an archive taken after the failure cannot be counted on to have them. The steps support needs belong at notice or above. 2. **Old lines may be gone.** The on-disk store purges old messages once it reaches its size limit. 3. **Redacted values stay redacted.** Strings logged with the default privacy appear as `<private>`; a hash mask is what lets support follow one renter. ## Reading entries in the app with `OSLogStore` `OSLogStore` (iOS 15) represents a set of unified log entries. On iOS an app opens it with `OSLogStore(scope: .currentProcessIdentifier)`. The `.system` scope and `OSLogStore.local()` are unavailable on iOS; `local()` is the Mac's local store and needs an admin user plus the `com.apple.logging.local-store` entitlement. ```swift import OSLog func recentCheckInLines() throws -> [String] { let store = try OSLogStore(scope: .currentProcessIdentifier) let start = store.position(date: Date().addingTimeInterval(-15 * 60)) return try store.getEntries(at: start) .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == "com.example.boatrental" } .map { "\($0.date) [\($0.category)] \($0.composedMessage)" } } ``` - `position(date:)` or `position(timeIntervalSinceEnd:)` gives a starting point; `getEntries(with:at:matching:)` returns a sequence of `OSLogEntry`. - Cast to `OSLogEntryLog` for the `level`, and read `subsystem`, `category`, `composedMessage` and `date`. - The scope is the **current process**: the export sees what this running process logged, not other processes, and not an earlier launch of the app. If the app was relaunched after the failed check-in, those lines are out of its reach, and an archive pulled from a Mac is the way to recover what the device kept. | | `log collect --device` | `OSLogStore` in the app | |---|---|---| | Needs | a Mac and the paired phone | iOS 15 and app code | | Sees | what the device kept, all processes | the current process only | | Best for | a tester or a renter at the desk | a report sent in the same session | ## A support checklist 1. Confirm the failing steps are logged at notice or above, with renter IDs hash-masked. 2. Ask for the approximate time of the failure, then collect with `--last` or `--start` around it. 3. Filter with `log show --archive ... --predicate` on the subsystem and category, adding `--info` and `--debug` in case those lines were captured. 4. Follow one renter by the shared hash value across the check-in steps. Uploading those exported lines to a server, with batching and scrubbing, belongs to the analytics pipeline, not to `OSLogStore`.

  • Can an iOS app open OSLogStore.local() or the .system scope to read other processes' logs?
    No. Both are unavailable on iOS and the compiler rejects them. `local()` is a macOS API that needs an admin user and the `com.apple.logging.local-store` entitlement. An iOS app opens `OSLogStore(scope: .currentProcessIdentifier)` and sees its own process's entries.
  • Why not pass --predicate to log collect to keep the archive small?
    The `log collect` help warns that a predicate can significantly increase the time and memory needed to collect. Collecting a bounded time range with `--last` or `--size` and filtering later with `log show --predicate` is the cheaper path.
  • The archive shows the check-in steps but every renter ID is <private>; can support unmask them from the archive?
    No. The archive shows those values as the redaction placeholder, or as a hash where a hash mask was used, and `log show` has no option to reveal them. To correlate one renter's lines, the app must log the ID with `privacy: .private(mask: .hash)` in the first place.

  • log stream --device streams a connected iPhone's logs live
  • An iOS app can read every process's logs with OSLogStore.local()
  • log show displays info and debug lines without extra flags
  • A collected archive reveals values that were logged as private
  • OSLogStore in the app can read lines from the previous launch's process