Want ro capture the debug in output file

I want to capture the debug for the below command in output file .

i tried like this but its not working:

sh -xv <scriptname> >> output.log

i want the output in a log file.

Anyone plz help in this

Stdout + stderr to output.log

sh -xv SCRIPTNAME >output.log 2>&1

Or just stderr:

sh -xv SCRIPTNAME 2>output.log

One query, is it a command or script?

For a single command, an alternative:

 sh -xv SCRIPTNAME | tee output.log

For a script, better to add below at start (ofcourse shell dependent):

 
# Below lines is added for debugging purpose.
set -xv