It somewhat depends on how the warnings are being produced - some functions may have specific options for suppressing / outputting warnings, for example.
The easiest approach is probably as elaborated HERE.
A quick example:
options(warn = 0) log <- file('log.out', open = 'wt') sink(log, type = 'message') warning('warning!') warning('Achtung!') warning('Aviso!') warning('Atenção!') sink(type = 'message') close(log)
Now execute it:
Warning message: warning! Warning message: Achtung! Warning message: Aviso! Warning message: Atenção!
By the way, setting
options(warn = 0) just ensures that warnings will be issued. Setting it to
options(warn = -1) would mean that warnings are not even reported anywhere.