Skip to content

Commit 5c05521

Browse files
committed
add example log commands
1 parent f747104 commit 5c05521

1 file changed

Lines changed: 49 additions & 7 deletions

File tree

README.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ sudo lsof -Pni TCP:22
13701370

13711371
Do not leave the computer unattended in unsafe locations. A skilled attacker with unsupervised physical access could install a [hardware keylogger](https://trmm.net/Thunderstrike_31c3) to record keystrokes, including passwords. Using a Mac with a built-in keyboard or a bluetooth keyboard makes this more difficult as many off-the-shelf versions of this attack are designed to be plugged in between a USB keyboard and the computer.
13721372

1373-
To reduce the consequences of theft while a Mac is in use, consider a theft-response tool such as [buskill/buskill-app](https://github.com/buskill/buskill-app) or [Lennolium/swiftGuard](https://github.com/Lennolium/swiftGuard).
1373+
To reduce the consequences of theft while a Mac is in use, consider using [buskill/buskill-app](https://github.com/buskill/buskill-app) or [Lennolium/swiftGuard](https://github.com/Lennolium/swiftGuard).
13741374

13751375
Consider purchasing a privacy screen/filter for use in public.
13761376

@@ -1380,15 +1380,57 @@ Consider purchasing a privacy screen/filter for use in public.
13801380

13811381
## Logs
13821382

1383-
Monitor system logs with [Console](https://support.apple.com/guide/console/toc) or the `/usr/bin/log stream` command.
1383+
Monitor system logs with [Console](https://support.apple.com/guide/console/toc) or the `log stream` command.
13841384

1385-
To show log entries generated by the `audioaccessoryd` process during the last hour:
1385+
Print all system logs from the last 5 minutes in classic syslog format:
13861386

13871387
```bash
1388-
/usr/bin/log show \
1389-
--last 1h \
1390-
--predicate 'process == "audioaccessoryd"' \
1391-
--style compact
1388+
log show --last 5m --style syslog
1389+
```
1390+
1391+
Output as JSON array:
1392+
1393+
```bash
1394+
log show --last 5m --style json
1395+
```
1396+
1397+
Output newline-delimited JSON (one JSON object per line); required for [jq](https://jqlang.org/download/):
1398+
1399+
```bash
1400+
log show --last 5m --style ndjson
1401+
```
1402+
1403+
Filter messages by subsystem, for example from `com.apple.SoftwareUpdate`:
1404+
1405+
```bash
1406+
log show --last 1h --style json \
1407+
--predicate 'subsystem == "com.apple.SoftwareUpdate"'
1408+
```
1409+
1410+
Filter messages by content, for example containing `failed`:
1411+
1412+
```bash
1413+
log show --last 1h --predicate 'eventMessage CONTAINS "failed"'
1414+
```
1415+
1416+
Case-insensitive message filtering:
1417+
1418+
```bash
1419+
log show --last 1h --predicate 'eventMessage CONTAINS[c] "error"'
1420+
```
1421+
1422+
Count distinct error messages with jq:
1423+
1424+
```bash
1425+
log show --last 1h --style ndjson \
1426+
--predicate 'eventMessage CONTAINS[c] "error"' |
1427+
jq -r '.eventMessage' | sort | uniq -c | sort -nr | head -100
1428+
```
1429+
1430+
Export logs to an archive, which can be opened with Console:
1431+
1432+
```bash
1433+
log collect --last 1h --output ~/Downloads/logs-$(date +%F-%H%M).logarchive
13921434
```
13931435

13941436
## DTrace

0 commit comments

Comments
 (0)