Logging the output of scp (and similar commands) doesn’t work the straightforward way of a simple redirection because scp uses direct terminal codes and if it detects a redirection, it doesn’t output anything.
Fortunately there is a command called script which is able to simulate a terminal so the output could be recorded.
To trace the output of
scp $REMOTE_SERVER:~/test/test.file /dev/null
Wrap a script command around
# fetch the file, but don't store it locally script -q -c "scp $REMOTE_SERVER:~/test/test.file /dev/null" 2>&1 | tee scpLog # replace carriage return with newline sed -i -e 's/\r/\n/g' scpLog
And your’e done