-1

I have a Windows service (c#, .net v4.5.2) that runs daily and is supposed to log errors to the Windows Event log (via System.Diagnostics) and errors plus progress information to the database (via log4net). Log4net is set to write "INFO" level.

Both logging mechanisms were working fine last time I looked, but last night the Windows service failed. I went to the d/b and event log and found that it hasn't written to either since 20th June, until it logged the automatic restart (to both logs) after it crashed last night.

Platform is a Windows 2012R2 VM in Azure. The service takes change-tracked SQL updates from a slave database, applies them to the master database, backs up the master and restores it over the slave, the log4net log is on the master. It's all been running fine, it just gave up logging.

Can anyone explain why it might have stopped logging to both log4net and the Windows event log?

Mike Dean
  • 67
  • 1
  • 3
  • 5
    Surely.. you are asking us to debug your environment, mind and code, and we can see none of them? The only thing i can think of is permissions have changed – TheGeneral Jul 11 '18 at 09:25
  • Not really. I want to know if anyone has experience of logging stopping for no obvious reason (the service itself has been running successfully) and if they managed to work out why. – Mike Dean Jul 11 '18 at 09:28
  • Did you check the user the service uses and if the password changed for it? – Alok Jul 11 '18 at 09:28
  • As I said, the service has been running successfully. It's just logging that's stopped. If it was just log4net that stopped I'd assume it was some sort of config error, but event logging also stopped. Question edited to add some context. – Mike Dean Jul 11 '18 at 09:30
  • K, I have a working hypothesis - related to this one https://stackoverflow.com/questions/26620785/log4net-stops-logging-and-have-to-restart-the-windows-service - I'll post up as an answer – Mike Dean Jul 11 '18 at 11:35

1 Answers1

0

The application server, domain controller and database server were all rebooted at the same time on the day log4net stopped logging. The likely cause therefore is that when the application server started up and the Windows service started, log4net was unable to connect to the database and shut down.

(Absence of Windows events probably a red herring - since the service was otherwise running happily without any errors, there just wasn't anything for it to write to Windows events.)

Mike Dean
  • 67
  • 1
  • 3