Print Friendly and PDF
Follow

Enabling VETtrak API logging

Logging can be enabled on the VETtrak API to log any errors that occur in the API, and optionally log every call that is made to the API (with each call's parameters).

To do so, edit the NLog.config file that is in the API's folder on the web server. This is an XML file.

There is an existing sample target element that logs to a file. You can modify this element to suit your needs. Change the folder in the fileName attribute to refer to a folder on the server to log to. This folder must exist, and the Windows user that the API's application pool is running under in Internet Information Services (IIS) must have write access to this folder (for a quick fix, you could grant Everyone write access to the folder). By default, the target will create a separate log file per day, but you can change this.

<target xsi:type="File" name="file" fileName="C:/logs/VETtrakAPI/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${logger}: ${message} ${exception:format=tostring:innerformat=tostring:maxInnerExceptionLevel=4}" />

Further down the file is a logger element that defines the logging rules. Change the "minlevel" attribute in this element to "Error" if you want to log errors only, or "Trace" if you want to log every call to the API (as well as errors).

<logger name="*" minlevel="Off" writeTo="file" />

Save the NLog.config file, and then restart the application pool that the API is running under in IIS.

When upgrading the API in future, don't replace your customised NLog.config file with the standard one from the API installation ZIP file.

NLog supports a variety of logging rules and targets that can be configured in the NLog.config file (such as automatically archiving logs, sending errors via email etc). For more information, refer to https://github.com/nlog/NLog/wiki/Configuration-file

Back to Top
    Tags:
  • api
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.