This project has moved. For the latest updates, please go here.

Integrate wlog in your application using Nlog

Download Wlog client library and include it in your poject as reference. This library uses "Newtonsoft Json.Net" library and NLog, so if your project dont use yet you'll have to add.

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.

Param in target:

  • 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

Last edited Dec 20, 2015 at 10:07 AM by zeppaman, version 2