Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write to Mac OS X Console logs from shell script or command line [closed]

Is there a simple, portable (preferably works with older OS X versions) way to write a message to the Mac OS X Console logs from a shell script?

like image 278
asmeurer Avatar asked May 29 '13 15:05

asmeurer


1 Answers

syslog -s -l error "message to send"

will log the message as something like

May 29 17:15:09 hostname syslog[22316]: message to send

You can customize things by using -k, which expects a list of alternating keys and values, for example

syslog -s -k Facility com.apple.console \
             Level Error \
             Sender MyScript \
             Message "script says hello"

would produce

May 29 17:22:21 hostname MyScript[22343]: script says hello

(setting the Facility to com.apple.console makes it a "console" message, equivalent to stdout output from a double-clicked bundled application, and retrievable using syslog -C)

like image 79
Ian Roberts Avatar answered Oct 24 '22 22:10

Ian Roberts