Search code examples
.netwindows-servicesinstallation

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.


Solution

  • 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.