Without timestamps:
#!/usr/bin/env bash
exec > >(tee -ai ~/app-stdout.log) 2> >(tee -ai ~/app-stderr.log >&2)
app $*
With timestamps (requires ts
from moreutils
):
#!/usr/bin/env bash
exec > >(tee >(ts '[%Y-%m-%d %H:%M:%S]' >>~/app-stdout.log)) \
2> >(tee >(ts '[%Y-%m-%d %H:%M:%S]' >>~/app-stderr.log) >&2)
app $*