How to log custom messages from inside a PostgreSQL transaction?
RAISE NOTICE is the right method.

The reason RAISE NOTICE output does not appear in clog.log is that your standard error redirection is wrong at the shell level.

You want: 

psql --log-file=plog.log -f file.sql  &gt;clog.log 2&gt;&amp;1


That way it redirects the standard output into clog.log and then the standard error to that standard output.

The way it's done in the question: 2&gt;&amp;1&gt;clog.log does not achieve that because of the wrong order, as described in the bash manual:


  Note that the order of redirections is significant. For example, the
  command
  
  ls > dirlist 2>&amp;1
  
  directs both standard output (file descriptor 1) and standard error
  (file descriptor 2) to the file dirlist, while the command
  
  ls 2>&amp;1 > dirlist
  
  directs only the standard output to file dirlist, because the standard
  error was made a copy of the standard output before the standard
  output was redirected to dirlist.