13

I've checked here and there's no option that can be passed to the Angular CLI to save logs to a file. I've tried this:

ng build |& tee output.txt

The problem is that the resulting file is crashing my Atom editor and in Geany it's unreadable, because of the characters like [BS], [ESC](their removal messes up formatting and the file is still unreadable).

Could you please share your tricks, good sirs?

manidos
  • 3,244
  • 4
  • 29
  • 65

1 Answers1

26

Try

ng build &> log.txt
Marcel
  • 568
  • 7
  • 12
  • 1
    Tried and got "The syntax of the command is incorrect" Tried without the '&'. Seemed to work initially but it turned the cmd window red and log.txt was empty. – user3217883 Apr 21 '22 at 15:20
  • @user3217883 what shell are you using? > is the default redirect operator in bash and & ensures that both stdout and stderr should be redirected. If you use > only, it would not redirect any errors to your file. Both variants should technically work without trouble. – Marcel Apr 22 '22 at 07:52
  • I was a cmd shell. I also tried a power shell. I didn't think about using a bash shell. – user3217883 Apr 23 '22 at 17:14
  • 9
    for windows try ng build > log.txt 2>&1 – fluf Apr 25 '22 at 06:32