from:https://github.com/NLog/NLog/wiki/WebService-target

Example config:

<nlog throwExceptions='true'>
<targets>
<target type='WebService'
name='ws'
url='http://localhost:1234/logme'
protocol='HttpPost'
encoding='UTF-8' >
<parameter name='param1' type='System.String' layout='${message}'/>
<parameter name='param2' type='System.String' layout='${level}'/>
</target>
</targets>
<rules>
<logger name='*' writeTo='ws'></logger>
</rules>
</nlog>

Example API controller

public class LogMeController : ApiController
{
/// <summary>
/// We need a complex type for modelbinding because
/// of content-type: "application/x-www-form-urlencoded"
/// in <see cref="WebServiceTarget"/>
/// </summary>
public class ComplexType
{
public string Param1 { get; set; }
public string Param2 { get; set; }
} /// <summary>
/// Post
/// </summary>
public void Post([FromBody] ComplexType complexType)
{
//do something
}
}

最新文章

  1. 分位数(quantile)
  2. HTML语言的一些元素(四)
  3. 2016 ACM/ICPC Asia Regional Qingdao Online HDU5889
  4. 详解WPF Blend工具中的复合路径功能 ( 含路径标记语法 )
  5. iOS 在类实现定义中声明成员变量的怪异方式
  6. SDUT1591交叉排序
  7. Yii rabc角色权限管理文章推荐
  8. 配置Delphi工具菜单 转
  9. JavaScript中的单引号和双引号报错的解决方法
  10. java中的序列化流和反序列化流
  11. 剑指offer编程题Java实现——面试题11数值的整数次方
  12. Oracle外键需要建索引吗?
  13. “百度杯”CTF比赛 九月场_SQL
  14. IE8 disable 兼容行问题
  15. mpvue开发小程序记录
  16. python 批量下载图片
  17. nginx unit nodejs 模块试用
  18. python第十四课--排序及自定义函数
  19. 最小子串覆盖 &#183; Minimum Window Substring
  20. 沉淀再出发:spring boot的理解

热门文章

  1. 用(*.frm *.MYD *.MYI)文件恢复MySql数据库
  2. 安卓开发之UIwebview
  3. Swift开发第十篇——可变参数函数&amp;初始化方法顺序
  4. iOS 学习 - 10下载(4) NSURLSession 会话 篇
  5. Fragment与Activity之间的通信
  6. 利用grep命令查找文件内容
  7. BIEE 目录迁移(文件夹)方式
  8. 初识Go
  9. 将dll程序集添加到缓存里
  10. boneCP原理研究