How to redirect all stdout/stderr to syslog

An easy way to redirect all stdout/stderr to syslog is to do the following in a bash script:

exec 1> >(logger -t MYTAG) 2>&1

Please note this only works with bash as this is a bash extension to the POSIX standard.

If you want only stderr:

exec 2> >(logger -t MYTAG)

So if you have an application that runs on the foreground (and a good app should not daemonize), you can have the following shell script for a quick solution:

#!/bin/bash
exec 1> >(logger -t YADIYADA) 2>&1
exec /PATH/TO/APP