If I run the installation the second time to update an existing installation, it writes to the same log file, but wipes out the log from last run. Can I make it log in append mode, so I can keep all the logs?

asked 08 Dec '12, 04:25

gt8967884's gravatar image

gt8967884
116747678
accept rate: 12%


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>

link

answered 09 Dec '12, 13:24

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

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>
link

answered 11 Dec '12, 04:18

gt8967884's gravatar image

gt8967884
116747678
accept rate: 12%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×26
×6

Asked: 08 Dec '12, 04:25

Seen: 1,302 times

Last updated: 11 Dec '12, 04:18