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?
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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With