How can I log Inno Setup installations?

sashoalm picture sashoalm · Feb 25, 2011 · Viewed 15.8k times · Source

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?

Answer

mirtheil picture mirtheil · Feb 25, 2011

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;