Reputation: 1154
Trying to get some basic ASP.NET Web API Tracing happening using NLog.
After a lot of searching the only documentation I could find is here: http://nlog-project.org/2010/09/02/routing-system-diagnostics-trace-and-system-diagnostics-tracesource-logs-through-nlog.html
The above isnt for the Web API but I have tried to adapt it, the problem seems to be in my Web.Config:
<system.diagnostics>
<sources>
<source name="System.Web.Http.ApiController" switchValue="All">
<listeners>
<add name="nlog" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="nlog" type="NLog.NLogTraceListener, NLog" />
</sharedListeners>
</system.diagnostics>
Any ideas why it's not working or references to an example?
Upvotes: 0
Views: 6450
Reputation: 27187
Yes I have written an article on how to implement NLog as an ITraceWriter
provider for Web API.
It was written against Web API RC but it should work fine with RTM as well: http://www.strathweb.com/2012/06/using-nlog-to-provide-custom-tracing-for-your-asp-net-web-api/
There is also an example on GitHub, by Dave Bettin - https://github.com/dbettin/webapi.nlog
Upvotes: 3