1

I have the following problem: I compile and run Rust program whose code I don't know too well using cargo run. It compiles fine, but somewhere in the code is a print/logging statement that prints way too many characters, causing the console to hang and Visual Studio code to crash. Due to the crash I can't read what is actually printed out which could help identifying the error.

Is there a way to print the output of cargo run to a text file?

I execute the command in Powershell, but the Powershell commands I tried (Start-Transcription and | Out-File -FilePath ...) do not capture what cargo is printing out.

cargo run > out.txt or cargo run >> out.txtalso prints only a few lines that are printed to the console by println!, but does not record the output of logging crates such as env_logger, which I would need.

Is there a way to achieve this? (My OS is Windows)

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Pux
  • 421
  • 3
  • 18
  • 1
    @Stargateur Thank you, that does indeed answer the question! – Pux Mar 09 '21 at 16:53
  • I think the posted answer did answer this question? It did for me after I tried doing what you did as well and followed one answer in [here](https://stackoverflow.com/a/32224971/8558585). I tried the `cargo run *> your_file.txt` – MikeTheSapien Jan 17 '22 at 07:50

0 Answers0