title: How to write error logs in Windows Service?
body: <p>I am new to Error Log. I am using this Code to write Error Logs.</p>
  
  <pre><code>public static void ErrorLog(string Message, bool BlnActvty)
  {
      StreamWriter sw = null;
      try
      {
          string sLogFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " ==&gt; ";
          string sPathName = Application.StartupPath;
          System.IO.Directory.CreateDirectory(sPathName);
          string sYear = DateTime.Now.Year.ToString();
          string sMonth = DateTime.Now.Month.ToString();
          string sDay = DateTime.Now.Day.ToString();
          string sErrorTime = sDay + "-" + sMonth + "-" + sYear;
          sw = new StreamWriter(sPathName + "ErrorLog_" + sErrorTime + ".txt", true);
          if (BlnActvty)
          {
              sw.WriteLine(sLogFormat + Message + "  On Inserting");
          }
          else
          {
              sw.WriteLine(sLogFormat + Message + "  On Updating");
          }
          sw.Flush();
      }
      catch (Exception ex)
      {
          ErrorLog(ex.ToString() + " On Error Log ", BlnActvty);
      }
      finally
      {
          if (sw != null)
          {
              sw.Dispose();
              sw.Close();
          }
      }
  }
  </code></pre>
  
  <p>By using the above Code i am writing Error Logs. But now, i want to write Error Logs in Windows Service.</p>
  
  <p>my Question is not in such a Range.</p>
  
  <p>I have Three Projects in a solution.One for Forms, Second for Classes and the other one is Windows Service.</p>
  
  <p>I want to write error logs in server where windows service is installed. Not in Systems where the Application is Installed. my application is running in  20 Systems in an Organisation. So in anywhere the Application get Error i want to write that error log in Server(Where the Service is Installed.). The Library is the One Which is Talking </p>