From: yawtd on
How about this approach:

{
{
cmd [--line-buffered] 3>&- |
tee stdout.log 2>&3 3>&-
} 2>&1 >&4 4>&- |
tee stderr.log 2>&3 3>&-
} 3>&2 4>&1 2>&1 | tee /dev/stderr > all.log

Inspired by: http://wiki.bash-hackers.org/howto/redirection_tutorial