I've got a standard electron app (based off of electron-prebuilt) that ought to be writing to std out with the following command: (in my project's main.js)
process.stdout.write('stdout write test')
when I launch the app from powershell and redirect the output to a txt file, I see the string displayed in the terminal window as expected:
> .\App.exe > log.txt
stdout write test
but when I open log.txt it's a blank file. what am I missing?
edit: to clarify Ansgar Wiechers' correct answer: in the windows command prompt, I needed to run the following command:
set ELECTRON_NO_ATTACH_CONSOLE=true
This results in console.log and process.stdout.write being directed to windows' stdout stream.
If you run .\App.exe > log.txt and you can see the output string in the console it means that the string is not being written to STDOUT (the Success output stream in PowerShell terms) in the first place.
Apparently the Electron developers decided to attach stdout directly to the console instead of actual STDOUT (see issue #4552). If I understand the discussion there correctly you can set the environment variable ELECTRON_NO_ATTACH_CONSOLE to avoid this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With