Can I make the installer log in append mode to keep all the logs for mulitple runs?

Comments

2 comments

  • Avatar
    wojciechka

    You can use scripts and <runProgram> to automate combining the log files.

    For example the below will create a .bat / .sh script that appends the log file to installation.log in ${installdir} - for both Unix and Windows:

    <if> <actionList> <writeFile> <path>${system_temp_directory}/combine_log_file.bat</path> <text>type "${installer_installation_log}" &gt;&gt;"${installdir}\installation.log" echo --- &gt;&gt;"${installdir}\installation.log" </text> </writeFile> <runProgram> <program>${system_temp_directory}/combine_log_file.bat</program> <programArguments></programArguments> </runProgram> <deleteFile> <path>${system_temp_directory}/combine_log_file.bat</path> </deleteFile> </actionList> <conditionRuleList> <platformTest> <type>windows</type> </platformTest> </conditionRuleList> <elseActionList> <writeFile> <path>${system_temp_directory}/combine_log_file.sh</path> <text>cat "${installer_installation_log}" &gt;&gt;"${installdir}/installation.log" echo --- &gt;&gt;"${installdir}/installation.log" </text> </writeFile> <runProgram> <program>sh</program> <programArguments>"${system_temp_directory}/combine_log_file.sh"</programArguments> </runProgram> <deleteFile> <path>${system_temp_directory}/combine_log_file.sh</path> </deleteFile> </elseActionList> </if>

  • Avatar
    gt8967884

    Combining logs looks too complicated to me. I'll just rename the old log to a different name.

    <!-- if old log file exists, rename it to <log_file>.log.<index> -->
    <actionGroup>
      <actionList>
        <setInstallerVariable name="index" value="1"/>
        <while>
          <actionList>
            <mathExpression>
              <text>${index} +1</text>
              <variable>index</variable>
            </mathExpression>
          </actionList>
          <conditionRuleList>
            <fileExists>
              <path>${project.installationLogFile}.${index}</path>
            </fileExists>
          </conditionRuleList>
        </while>
        <renameFile>
          <origin>${project.installationLogFile}</origin>
          <destination>${project.installationLogFile}.${index}</destination>
        </renameFile>
      </actionList>
      <ruleList>
        <fileExists>
          <path>${project.installationLogFile}</path>
        </fileExists>
      </ruleList>
    </actionGroup>
    

Please sign in to leave a comment.