1

At my work we have some old 'services' which are actually Console applications which run 24/7 on our servers. Finally we decided to replace it with Windows Services, but now we can see from each console window when there are errors or certain events (like too many requests etc.)

Now the idea came up to let every windows service write in a database every minute (so we can see if the service hasn't stopped), and also write in the database when there's certain events (like the many requests).

Now I've been thinking about hosting a WCF Service in each of the windows services instead, because I think there's more possibilities (and I don't really like the idea of our databases having data inserted from 10+ services every minute) and it's still possible to write an application which sends requests to the WCF services every x amount of time.

Are there any downsides of WCF vs the approach of writing in a database? In a database of course it's easier to keep the data until it's been read, but that's only one (small) issue I can think of.

Thanks in advance!

Alexander Derck
  • 11,742
  • 4
  • 43
  • 73

1 Answers1

1

I would have go with the follow options:

  1. As you suggested, create WCF endpoint and verify you services are on. You will still need to implement error escalation. I like to use ELMAH

  2. Using a watchdog How can I verify if a Windows Service is running

For the events, log services activities using a logger such as log4net or Nlog. Then append it to DB/Email/File. My favorite is to manage logs using ELK (Elastic/Logstash/Kibana) or Splunk.

Community
  • 1
  • 1
Amir Katz
  • 937
  • 1
  • 9
  • 22
  • Yes we already use log4net with RollingFileAppender/DbAppender but I don't really like the thought of services constantly writing in a database. For certain events it would be fine i guess – Alexander Derck Dec 22 '15 at 20:36
  • I see what you are saying. If the events are debug/info/error logs then this is perfectly fine to use log4net and any appender you would like. If the logs are business logic events such as milestones on flow etc. This should be a part in your data model, thus can be persisted in the DB with your model. – Amir Katz Dec 22 '15 at 20:55
  • I don't get your last sentence, events part of data model? – Alexander Derck Dec 22 '15 at 20:58
  • 1
    "errors or certain events" - if the certain events are part of your business process they should be persisted with your application model. i.e. you are programming a stackoverflow website and a user has voted V for an answer this is a business application event and should be persisted with user and all other information in the DB. – Amir Katz Dec 22 '15 at 21:04
  • 1
    Oh okay, it's not like that in my case. After looking into the `ServiceController` class I'm definitely going to use that for the status of my services and stick to log4net for events. Thanks a lot, this site never lets me down :) – Alexander Derck Dec 22 '15 at 21:07