-1

We are using Log4Net for log purpose in Windows Service (running under user account) and all rollover files do have timestamp appended in the fileName.

We discovered that the time in fileName was off by 12 hours and 30 mins. The windows service in running in client machine hosted in PST time zone and the code was compiled in India, which we believe is some how related since the time is logging corresponds to IST time.

Code is in C#, .Net 3.5 and VS 2008

Any idea how to correct this?

  • Do you have any settings in the Log4Net configuration file specific to datetime format or zone? – Bernd Linde Apr 20 '15 at 13:51
  • 1
    It may depend on how the file name is generated. If it is done by Log4Net then it should be able to be controlled by the xml config [like this](http://stackoverflow.com/questions/1165084/log4net-rolling-daily-filename-with-date-in-the-file-name). There is also the chance that the file name is generated by the client process in which case I would be highly suspicious that it might be hard-coded. – jzapata Apr 20 '15 at 13:53
  • The service it is supposed to take local time (machine time) and create logs with same. so in PST zone it should take machine time which is in PST not IST – user1985896 Apr 21 '15 at 03:33

1 Answers1

2

Without a user set on your service's Log On tab, your service will run in the Local System account which has its own regional settings. Perhaps that account is currently set to IST.

Follow these instructions to change the regional settings of the System account.

CoreTech
  • 2,345
  • 2
  • 17
  • 24