Ray
Ray

Reputation: 46585

Write to InstallLog from Installer

How do I write to the InstallLog from a service installer?

I've overridden the OnBeforeInstall method of my class (which derives from System.Configuration.Install.Installerand now I want to write to the installer log. But I can't see anything that would allow me to do this.

Console.WriteLine will write to the console but not to the log.

Upvotes: 4

Views: 1809

Answers (2)

Dennis
Dennis

Reputation: 61

I just create my own log.

public void SetupLog(string sLine) {
     using(StreamWriter w = File.AppendText("c:\\mysetup.log")) 
        w.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {sLine}");
  }

Upvotes: 0

Yan Sklyarenko
Yan Sklyarenko

Reputation: 32260

As far as I can see, there's a property called Context in the Installer class. It has type InstallContext. That type has the method LogMessage(), which I suppose is what you need. See this article for more information about LogMessage() method.

Upvotes: 4

Related Questions