How to log the eval metrics every `eval_steps` to a file?

I am using Trainer to train a model, and I set eval_strategy='steps' and eval_steps=1000, then I can see the metrics in the terminal:

My question is, how can I log these information into a local file? Cause I’m using a remote server to run my code, when my connection is broken, all the information during the training gets lost, I can only get the final results.

@sgugger could you please help me?