$Messages
gives the list of files and pipes to which message output is sent.
Examples
Basic Examples (2)
The default channel for messages is standard output:
Have messages go to a temporary file and the default channel:

Show the contents of the temporary file:
Clean up by resetting $Messages to its default and closing the stream:
Wolfram Research (1988), $Messages, Wolfram Language function, https://reference.wolfram.com/language/ref/$Messages.html.
Text
Wolfram Research (1988), $Messages, Wolfram Language function, https://reference.wolfram.com/language/ref/$Messages.html.
CMS
Wolfram Language. 1988. "$Messages." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/$Messages.html.
APA
Wolfram Language. (1988). $Messages. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/$Messages.html