PowerShell - Start-ChocolateyProcessAsAdmin should log to stdout and not stderr
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
When running with powershell.exe as an external process, it adds all output messages as stderr to the CLIXML stream when those logging streams are not info or output. This behavior seems incorrect.
Related to #901
### Details
If you see `Exited with '0'`, it means it is good - those are not actually errors. Bear with me a second - so when you call `Start-ChocolateyProcessAsAdmin`, it calls that process which runs in a separate PowerShell process to perform that work. PowerShell logs on multiple streams - `DEBUG`, `VERBOSE`, `INFO` (stdout), `WARN`, and `ERROR` (stderr) streams. However, when it exits and needs to provide those logs back to an exe (like choco.exe), it needs to combine those streams together as there is only stdout and stderr. You can probably guess what it does with `DEBUG`, `VERBOSE`, and `WARN` - straight to stderr, which makes it appear that there is an error that occurs when it is in fact just capturing the logs. Having it come back in CLIXML is also not helpful to deduce this is not an issue. We need to find a better way to log that.
Contributor guide
Assessment
This issue has not been assessed yet.