How can I log Inno Setup installations?

inno-setup, logging

Solution

You can set the `SetupLogging` option (`SetupLogging=yes`) then integrate the following code into your script to copy the log somewhere.

procedure CurStepChanged(CurStep: TSetupStep);
var
  logfilepathname, logfilename, newfilepathname: string;
begin
  logfilepathname := ExpandConstant('{log}');
  logfilename := ExtractFileName(logfilepathname);
  newfilepathname := ExpandConstant('{app}\') + logfilename;

  if CurStep = ssDone then
  begin
    FileCopy(logfilepathname, newfilepathname, false);
  end;
end; 

Problem

Inno Setup has command line parameter `/LOG="filename"`. Can I specify a log filename from inside the Inno Setup script, so I can include it later in my error reports?

Original source