Search code examples
electronnsiselectron-builder

Activate logging in electron-builder NSIS Installer


I am trying to generate the log for NSIS installer for my electron app. To achieve it I have created a file 'logging.nsh' to define the LogSet and LogText macros. Below is the code for logging.nsh file:

!define LogSet "!insertmacro LogSetMacro"
!macro LogSetMacro SETTING
  !ifdef ENABLE_LOGGING
    LogSet ${SETTING}
  !endif
!macroend

!define LogText "!insertmacro LogTextMacro"
!macro LogTextMacro INPUT_TEXT
  !ifdef ENABLE_LOGGING
    LogSet ${INPUT_TEXT}
  !endif
!macroend

installer.nsh

!define ENABLE_LOGGING
!include "logging.nsh"

!macro preInit
     SetOutPath $INSTDIR
     ${LogSet} on
!macroend

When I build my installer I am getting the error saying **NSIS_CONFIG_LOG is not defined** On checking the NSIS forum I figured out NSIS_CONFIG_LOG should be defined at compile time for LogSet to work. Reference: http://nsis.sourceforge.net/Reference/LogSet. I am not able to figure out how I can define NSIS_CONFIG_LOG at compile time for my electron app. Any Suggestions will be appreciated Or if there is any other way I can generate logs for my electron app's NSIS installer.


Solution

  • NSIS itself (makensis and the stubs) needs to be built with the logging turned on for LogSet to work.

    You can download a logging build from the NSIS website.