- Your backslashes are escaped, in a string enclosed with double quotes you need to double them, or just use the Unix notation.
So
"C:\\Users\\---\\Desktop\\mylog.log"
or "C:/Users/---/Desktop/mylog.log"
or 'C:\Users\---\Desktop\mylog.log'
- Paths in Ruby are safest in Unix notation, so even when you use backslashes for ease of copying you are better to convert them to Unix formatting.
like this 'C:\Users\---\Desktop\mylog.log'.gsub('\\','/')
The double backslash is also needed here, the ' and \ need to be escaped using single quotes.
Another tip not relevant tot the question but very handy: use the block method to open a file so that it is clear when the file is closed, see this example
File.open(path, 'w') do |file|
file.puts "Hello"
end
The file is closed after the end.
For logging though, take a look at logger, once you used it you won't stop using it.