-
Notifications
You must be signed in to change notification settings - Fork 6
integrate wlog using nlog
JanickGers85 edited this page Nov 1, 2016
·
6 revisions
Download Wlog client libraries and include it in your poject as reference. You'll need to download the following:
- Wlog.Clients
- Wlog.Clients.NLog
These libraries uses "Newtonsoft Json.Net" library and NLog, so if your project dont use yet you'll have to add them.
After that you have to change configuration settings as below:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" >
<extensions>
<add assembly="NLog.WebLog"/>
</extensions>
<targets>
<target xsi:type="BufferingWrapper"
name="wlog.loggerWithBuffer"
slidingTimeout="True"
bufferSize="1000"
flushTimeout="100">
<target xsi:type="WebTarget" destination="http://localhost:55044/api/log"
ApplicationKey="{8C075ED0-45A7-495A-8E09-3A98FD6E8248}"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
</target>
</targets>
<rules>
<logger name="wlog.loggerWithBuffer" minlevel="Info" writeTo="wlog.loggerWithBuffer" />
</rules>
</nlog>
Note that in this example we use only our target; it is useful to log also in a local file appender to avoid to lost logs in case of network issues.
- ApplicationKey="{8C075ED0-45A7-495A-8E09-3A98FD6E8248}" : use guid of your application; this is the guid of preconfigured sample application
- destination="http://localhost:55044/api/log": it's the url of you serve api, change accordlyung with your server