Skip to content

Logging to WebService

Konrad K Sobon edited this page Jul 30, 2018 · 3 revisions

ZombieService allows you to log events to an endpoint/WebService. If you have a WebService setup that accepts a HTTP POST request, then ZombieService can log to it. Here's what to expect and how to set it up:

Setup ZombieService so that it sends POST requests on log events.

  1. First we need to tell ZombieService that we even want to log to a database/web service. By default ZombieService will be setup to only log to a local file. That file will be located in a {basedir}/logs. In order to add a webservice to it, just add a 4th argument to the command line arguments when Zombie Service is launched.

ZombieService.exe ZombieSettings AccessToken WebServiceEndpoint

  • First argument is a path to ZombieService.exe file that will be launched.
  • Second argument is a path to ZombieSettings. This can be a path to remote settings like a public repo on GitHub.
  • Third argument is an Access Token for a GitHub repo that Zombie will pull Releases from.
  • Fourth argument is a path to Web Service REST API endpoint that is capable of consuming a POST request. An example of such endpoint: http://localhost:8080/api/v2/zombielogs

Setup a Schema for the database. Here's what the JSON payload will look like:

{
    "source" : "ZombieService.Runner.RunnerUtils.PublishGuiUpdate at line: 259",
    "exception" : "",
    "machine" : "NY-FWR-L011",
    "level" : "Info",
    "version" : "0.0.2.19689",
    "createdAt" : ISODate("2018-07-27T15:02:16.747Z"),
    "message" : "This is some message!"
}
  • source - this is a Namespace\Class\Method and a line number that the exception or log event occurred at.
  • exception - this is the actual exception message that was generated.
  • machine - Environment.MachineName which helps identify what computer the issue occurred on when we are distributing Zombie across a larger company.
  • level - level of the log event: Info, Debug, Fatal etc.
  • version - version of the EXE that the log occurred in. In this case it would be version of the Zombie Service.
  • createdAt - a timestamp
  • message - either a message when level was info since no exception occurred, or the message that was created with the exception.

In my case I setup a MEAN app (Node.js and MongoDB), and just created a new collection in the Database to store the logs in. You can use these logs to monitor the state of whatever ZombieService was supposed to keep up to date. In my case I am distributing Revit plug-ins.