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