ITKeyword,专注技术干货聚合推荐

注册 | 登录

解决NLog - ASP.Net Web API Tracing

itPublisher 分享于

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

推荐:ASP.NET Web API

ASP.NET Web API includes support for the following features: Modern HTTP programming model: Directly access and manipulate HTTP requests and responses

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>
    <
 dListeners> <add name="nlog" type="NLog.NLogTraceListener, NLog" /> </
 dListeners> </system.diagnostics>

Any ideas why it's not working or references to an example?

asp.net-web-api nlog
|
  this question
asked Feb 2 '13 at 0:47 ServerMonkey 403 1 9 28

 | 

1 Answers
1

解决方法

Yes I have written an article on how to implement NLog as an ITraceWriter provider for Web API.

推荐:ASP.NET Web API :Web宿主

上一节描述了API的整个运行框架,即分为三层hosting、message handler pipeline 和 controller handling。此节讲其中一个宿主,WebHost 寄宿在asp.net 传统管道

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


|
  this answer
answered Feb 2 '13 at 1:02 Filip W 21.8k 3 73 78

 | 

推荐:asp.net web api

官方的地址: http://www.asp.net/web-api 里面的资料很全,是学习的第一选择.建议多参考此资料 1.里面最简单直接的例子 http://www.asp.net/web-api/overview/get


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。