logger
has an -s
flag:
-s Output the message to standard error as well as to the system
log.
Source: LOGGER(1) Man Pages
You can use the -s
to log the message to standard error.
Then redirect stderr to stdout and then stdout to /dev/null
.
Pipe the whole thing into tee
, and you'll end up with your message in your syslog as well as the path you specified in tee
.
Example:
joeyoung$ logger -s -p local0.notice -t TEST "test message" 2>&1 >/dev/null | tee -a /tmp/teetemp.log
Oct 3 11:11:54 localhost TEST[4231] <Notice>: test message
joeyoung$ tail -n1 /var/log/messages
Oct 3 11:11:54 localhost TEST[4231]: test message
joeyoung$ cat /tmp/teetemp.log
Oct 3 11:11:54 localhost TEST[4231] <Notice>: test message
For proper attribution, some inspiration taken from: https://stackoverflow.com/a/2342841/2744166