I'm trying to log events/check-points from my shell-script using logger.

How to use logger or syslog utility in OS X (version 10.12 (16A323)). I have tried

logger "Hello world" and checked /var/log/system.log using Console app, the following was the log entry created

Failed to harvest strings for binary named '–Xó^H'

How to use logger in OS X ? Is there anything to be specified to create/add an entry to OS X system log ?

  • Could you please improve your question by mentioning why you want to? That might help people find options for you. – Harv Oct 11 '16 at 5:51
  • I was able to successfully log an entry: $ logger "This is an log entry" $ echo $? 0 Then when I checked "All messages" in my Console, my message showed up. – Harv Oct 11 '16 at 5:54
  • 1
    Exited with status code 1, no output. I tried with logger. – SG_ Oct 11 '16 at 6:41
  • 3
    I too see no Hello World in any /var/log/*.log file. The behaviour @SG_ is seeing, is reproducible on my Mac running macOS 10.12. Additionally, logger -s 'Hello World' does correctly print to the console but not to any on-disk log file. – Graham Miln Oct 11 '16 at 7:22
  • 2
    Not showing up in system.log for me, but if I view "all logs" in console, it does show up there. Odd! – Harv Oct 11 '16 at 14:56

Because Apple's logging system changed in macOS sierra. They are moving from the Apple System Log facility to unified logging.

Here's a link to the developer documentation.

The following filters the new unified log for text "Message4me"

$logger -is -t LogTest "Message4Me" 
Oct 15 13:19:27  LogTest[51173] <Notice>: Message4Me

$log show --predicate 'eventMessage contains "Message4Me"' --last 3m

Skipping info and debug messages, pass --info and/or --debug to include.
Filtering the log data using "eventMessage CONTAINS "Message4Me""
Timestamp                       Thread     Type        Activity             PID    
2016-10-15 13:19:27.666574+0900 0x33b62c   Default     0x0                  51173  logger: Message4Me
Log      - Default:          1, Info:                0, Debug:             0, Error:          0, Fault:          0


If you add --info you will see the event message itself in the output as well.

In the previous OS versions the logger command would send to the /var/log/system.log file if the priority was high enough (e.g. using -p alert) as well as to the syslog database. In Sierra the system.log is not written to when logger is used with -p alert -not in 10.12.1 anyway. This could be a bug.

You can still use logger to send to he new logging system, but will have to use the Console app or the cli log utility or the new API to see the results.

  • 1
    This is almost a link-only and a "maybe" answer. A ~layman won't understand what your commands mean. Please add some explanation. – klanomath Oct 15 '16 at 11:55
  • 1
    Four months later, and the link is already broken. – John Smith Mar 1 '17 at 5:16
  • I think the current link is: developer.apple.com/reference/os/logging – ktappe May 30 '17 at 18:12

I solved this issue by having a script that uses netcat to send specific logs every 10min from a launchdaemon. Edit as needed.


while read line    
    #drop log entries in the log file you don't want to sent to syslog server
   if [[ "$line" =~ ^.*recurring\ check-in.* || "$line" =~ ^.*Executing\ Policy\ Update\ Inventory.* ]]; then
     /bin/echo "" > /dev/null;
     ## send logs to syslog server using netcat. Edit IP and UDP port as necessary
     echo $line | nc -v -u -w 0 514
done < /var/log/system.log

This is no real answer but a workaround and too long for a comment.

I faced the same problem in Sierra trying to log a homebrew update shell script including logger commands (which worked in El Capitan). I had to abandon logger and simply used echo, output redirection and a new log file:



echo "$(date "+%Y.%m.%d %H:%M:%S")" >> $Brewup_Log 2>&1
$Brew update 2>&1 >>$Brewup_Log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .