There are two streams, stdout and stderr. stdout is standard output and stderr is where error messages go.
Code:
ls -l > file.txt # will dump only stdout to file.txt
ls -l 2> file.txt # will dump only stderr to file.txt
ls -l &> file.txt # will dump both streams to file.txt