node.jselectronelectron-buildernode-addon-apinode-native-addon

Print node terminal/main.js log to renderer console (developer tools)


I have a electron app which is using c++ native addon in it.

C++ code prints log to terminal and while development I can see them in termianl.
Electron app log in renderer.js console (developer tools console).
The same thing does not happen after building app executables, as there is no termianl there...

So after build I can only see renderer.js log and can't access log from main.js and c++ code.

ISSUE:
How can I print terminal log and main.js log to renderer console.


Solution

  • You can start your packaged Electron app from the command line with this argument --enable-logging to see the main process console output on your terminal.

    I suggest that you look into some kind of logging library like electron-log instead of trying to print main process logs inside the renderer process.