I'm not sure just how specific this is, but when I run 'brew doctor' I see some error messages. If I want to save those messages I run
brew doctor > brewErrors.txt
Exactly how you fix this depends on your shell. But the problem is that
> redirects STDOUT and generally error messages appear on STDERR. Every unix process has 3 file descriptors open by default (
STDIN, STDOUT, STDERR).
This is how you would run the command to save STDERR to a file in bash.