echo to stderr and tee to log file?

bash

Solution

To echo the text to both the log file and stderr, but not stdout, try this:

echo "error" | tee -a log 1>&2

Problem

In bash script, echo "error" 1>&2 | tee -a log will print stderr in screen but no log to file, how to do these at same time?

Original source