title: How to create a custom event log using C#
body: <p>I created a Windows service. I create an event log.</p>
  
  <pre><code>public Service1()
  {
          InitializeComponent();
          this.ServiceName = ConfigurationManager.AppSettings.Get("ServiceName");
  
          string sourceName = ConfigurationManager.AppSettings.Get("ServiceName");
          string logName = ConfigurationManager.AppSettings["EventLogName"];
          try
          {
              if (!System.Diagnostics.EventLog.Exists(sourceName))
                  System.Diagnostics.EventLog.CreateEventSource(sourceName, logName);
              eventLog.Source = sourceName;
              eventLog.Log = logName;
          }
          catch
          {
              eventLog.Source = "Application";
          }
      }
  </code></pre>
  
  <p>During initialization, the service is installed and log is not created. The log entries are in the <code>Application</code> log of the system.</p>
  
  <p>What did I miss?</p>
  
  <p>I used process installer to installation</p>
  
  <pre><code> public ProjectInstaller()
   {
          InitializeComponent();
          this.Installers.Add(GetServiceInstaller());
          this.Installers.Add(GetServiceProcessInstaller());
   }
  
   private ServiceInstaller GetServiceInstaller()
   {
          serviceInstaller.ServiceName = GetConfigurationValue("ServiceName");
          serviceInstaller.Description = GetConfigurationValue("Description");
          serviceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
          return serviceInstaller;
   }
  
   private ServiceProcessInstaller GetServiceProcessInstaller()
   {
          serviceProcessinstaller.Account = ServiceAccount.LocalSystem;
          return serviceProcessinstaller;
   }
  </code></pre>
  
  <p>How to create event log?</p>