I want to setup a global logger and write the logging messages into a file. Here is what I did for this purpose.
module Example using Logging function setlogger() io = open("/tmp/log.txt", "w+") logger = SimpleLogger(io) global_logger(logger) return nothing end function closelogger() close(global_logger().stream) end function test() setlogger() @info "Test message" @info "Test message" closelogger() end export setlogger, test, closelogger end
and here is the console output when I tested logging
julia> using Example julia> test() [ Info: Test message [ Info: Test message
The problem is that the logging messages are written into the console, not in the file
/tmp/log.txt which is empty.
Any ideas what I am doing wrong?