How to log all output in console to file?

I want to log all outputs in console into a file, including all records automatically generates at run time.

For example, when I use Mosek to solve some problems, I need these data logged in the output file. These data are automatically generated in console.

image

Can Julia do this? Thanks!

In this example, I wrote this Mosek slover in a function like,

function sol! (...)
    model = Model(with_optimizer(Mosek.Optimizer))
    ...
    optimize!(model)
    return
end

So, how can I log function “sol!(…)” in a file?