- 1 year ago
How to log ng command output in proper format?
Comment
1 / 1
To log the output of an ng
(Angular CLI) command in a proper format, you can use a combination of PowerShell (on Windows) or Bash (on Linux/macOS) along with Angular CLI's output redirection. Here's how you can do it:
Windows (PowerShell)
In PowerShell, you can use the Start-Transcript
cmdlet to capture the entire console session, including the output of the ng
command, into a log file.
powershellStart-Transcript -Path "ng_log.txt" -Force
# Run ng command
ng <command>
# Stop transcript
Stop-Transcript
Linux/macOS (Bash)
In Bash, you can use the tee
command to capture the output of the ng
command and redirect it to both the console and a log file.
bash# Run ng command and log output
ng <command> 2>&1 | tee ng_log.txt
Replace <command>
with the actual ng
command you want to run.
Both approaches will capture the output of the ng
command and save it to a log file. Choose the appropriate method based on your platform.