If I run R script under command line (actually I run that from calling in VBA), how can I output any error/warning messages to a txt file?
To close the connection with the log file you have to use sink(type="message") instead of sink() and then close(zz).
sink(type="message")
sink()
close(zz)