-
Notifications
You must be signed in to change notification settings - Fork 0
Integrate HubLink using NLog
Daniele Fontani edited this page Apr 2, 2017
·
3 revisions
Download Wlog client libraries and include it in your poject as reference using NuGet.
Install-Package NLog.HubLink.Clients
This will install HubLink libs and their references.
- HubLink.Clients
- NLog.HubLink.Clients
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.Wlog.Clients"/>
</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 according with your server
Use it as usual. All log sent to HubLink logger will be forwarded to the server. For performance issues best option is to keep debug\trace logs using a local file system appender, but send more important levels (info, error..) to the server. This may vary from application to application basing on how levels are defined and used.