The normal output and the error output are different things, although we experience them as the same in most of the cases.
The OS sends both normal and error output to the standard output device, which is usually our display/screen.
When you are using the "--log-file" clause, you are telling the psql to redirect the normal output to the file indicated, but the error output keeps being sent to the standard output device.
To redirect the error output you have to append it to the file you're logging into.
To do that, do the following (both Win and Linux, replace the psql arguments ofr yours) :
The ">>" sign tells the OS to append to the file, if you use ">" it will overwrite it, and you dont want to overwrite it because you are already writing on it with the "--log-file" clause.