Where is /var/log/messages on macOS? Understanding System Logging Alternatives


3 views

If you're coming from a Linux background, you might be surprised to find that the traditional /var/log/messages file doesn't exist on macOS. While Unix man pages often reference this path, macOS implements system logging differently.

macOS uses a unified logging system introduced in OS X 10.12 (Sierra) that replaces traditional text log files. The system consists of:

  • os_log: The API for submitting log messages
  • log: Command-line utility for viewing logs
  • Console.app: GUI application for log viewing

Instead of /var/log/messages, use these alternatives:

# View system logs in terminal
log show --predicate 'process == "kernel"' --last 1h

# Filter logs by subsystem
log show --predicate 'subsystem == "com.apple.network"' --info

# Export logs to a file
log show --last 24h > system_logs.txt

Some legacy logs might still exist in these locations:

ls -l /var/log/*.log
ls -l /Library/Logs/
ls -l ~/Library/Logs/

If you really need a messages-style log, you can create a script:

#!/bin/bash
# Create daily log archive
DATE=$(date +%Y-%m-%d)
LOG_DIR="/var/log/custom"
mkdir -p "$LOG_DIR"
log show --last 24h > "$LOG_DIR/messages-$DATE.log"
gzip "$LOG_DIR/messages-$DATE.log"
  • macOS logs are binary-format by default
  • Logs are stored in a compressed, indexed database
  • Privacy controls may restrict access to some logs
  • Log rotation is handled automatically

For applications that hardcode this path, consider:

sudo mkdir -p /var/log
sudo ln -s /dev/null /var/log/messages

If you're coming from a Linux background and trying to find system logs in /var/log/messages on macOS, you'll quickly discover this file doesn't exist. The command:

$ ls -l /var/log/messages
ls: /var/log/messages: No such file or directory

This can be confusing since some man pages still reference this path. macOS handles system logging differently than traditional Unix/Linux systems.

macOS uses a unified logging system introduced in OS X 10.12 (Sierra) and later. The main components are:

  • os_log: The API for sending log messages
  • log: Command-line tool for viewing logs
  • Console.app: GUI application for log viewing

Instead of /var/log/messages, use these alternatives:

# View system logs in terminal
$ log show --predicate 'eventMessage contains "error"' --last 1h

# Filter logs by process
$ log stream --predicate 'process == "kernel"'

For persistent logs, check these locations:

/var/log/system.log
/Library/Logs/
~/Library/Logs/

Here's how to work with macOS logs programmatically:

// Swift example using os_log
import os.log

let log = OSLog(subsystem: "com.yourcompany.yourapp", category: "network")
os_log("Network request started", log: log, type: .info)

To read these logs from command line:

$ log stream --predicate 'subsystem == "com.yourcompany.yourapp"' --level debug

Some legacy applications might still use traditional log files. These are typically found in:

/var/log/install.log
/var/log/com.apple.xpc.launchd/

You can view these with standard tools:

$ tail -f /var/log/install.log
$ grep -i error /var/log/system.log

To manage log storage on macOS:

# Check current log settings
$ sudo log config --status

# Change log retention policy
$ sudo log config --mode "level:debug" --subsystem "com.yourcompany.yourapp"