Logging to Syslog from the command line
Whilst reading about Heroku’s logging on Adam’s blog I came across logger,
a tool available on most unix systems which takes any input on STDIN, and redirects it to syslog with the provided options. I’d never heard of it,
so I assume there’s some other people who havn’t either, and are doing as I have in the past and messing around with far more convaluted ways of getting
output routed to syslog.
The gist of it is:
echo "This will be logged" | logger -i -p local0.notice -t EXAMPLE
Which results in the following line in /var/log/syslog on my machine:
May 10 11:25:52 imac EXAMPLE[38038]: This will be logged
See man logger for full details.