4

I am tailing the system.log on a mac:

tail -f -n 0 /var/log/system.log 

but I can't figure out how to write to this log. It does seem to be the main log on the machine. I tried:

logger foobar # didn't work syslog -s -l error "message to send" # didn't work 

anyone know how to write to the system.log on a Mac?

update:

if I run: log stream

and then use:

logger -is -t krypted "Hello L" 

it will show up in the stream, but not in /var/log/system.log. weird.

1
  • note that on ubuntu for example, logger xyz will log to /var/log/syslog, but on macos, this file appears to be /var/log/system.log, but using logger doesn't seem to write to it by default Commented Oct 4, 2019 at 6:18

1 Answer 1

7

The streaming messages are part of a binary log file. Apple are moving to a unified logging system, so the logs do not work the same way anymore, at least by default. One might try to configure syslogd and/or ASL (Apple System Logger) via one or both of the configuration files, /etc/syslog.conf and /etc/asl.conf. (There are many more configuration files for ASL stored in /etc/asl.) This might involve grokking manual pages to learn how to produce plain text log files for certain messages. Some of these manuals might be man 1 log, man 1 syslog, man 5 syslog.conf, and man 8 syslog. I have not yet determined exactly how to do this, but I wanted to give you some sort of method to produce, view, and "tail" custom messages. (I'll come back and update this answer if I ever do learn how to send certain messages to a plain text file by configuring their new logging system. It seems that it, at least, can be done, because there do exist plain text files in /var/log.)


One can send messages with syslog -s and logger. (The -s option sends log messages to syslogd, and syslog can do more than logger.) An easy way to follow the logs in a similar way to tail is to utilize Console.app. Open the program and place the cursor on the local machine listed under Devices. In the search field, provide the name of the program that was used to send the message: one of syslog or logger. Next, open a terminal and send a message.

syslog -s "test message" 

The message can then be seen in the Console as illustrated below.

Snippet of Apple Console

Messages can be acquired from the logs. Use the --info and/or --debug options to specify lines that log would ignore by default. Specify which process sent the syslog message within the --predicate option.

log show --info --debug --predicate "process == 'logger'" 

or

log show --info --debug --predicate "process == 'syslog'" 

To get an effect similar to tail, use the stream command.

log stream --info --debug --predicate "process == 'logger'" 

or

log stream --info --debug --predicate "process == 'syslog'" 

After starting the stream, send a message to witness that it does behave in a similar way to tail, as illustrated.

Apple log command streaming

The command, syslog -s "test message" was used to send the messages.

3
  • More log-released resources: eclecticlight.co/consolation-t2m2-and-log-utilities Commented Nov 23, 2020 at 20:16
  • 2
    I tried (in Mojave) to open Console and search for ANY:syslog and entered the syslog -s "test message" but nothing shows up. Commented Nov 24, 2020 at 14:39
  • 1
    @gctwnl Since I wrote the answer Console has gotten weird. Try the command line. Still works great for me on Big Sur and Mojave. Commented Nov 25, 2020 at 15:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.