netframework webapi exceptionless
1、webapi项目 添加nuget exceptionless webapi
2、在exceptionless server端添加项目,注意key
3、修改api项目的webconfig
<appSettings>
<add key="Exceptionless:ServerUrl" value="http://47.93.86.137:9001"/>
</appSettings>
<exceptionless apiKey="eUqwA9AQ8DUiR5WGf3XCPNfj3OOXyz7CuCTIgyR5" />
4、修改global
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
GlobalConfiguration.Configuration.Filters.Add(new LogFilterAttribute());
log4net.Config.XmlConfigurator.Configure(new FileInfo(Server.MapPath("~") + @"\Config\Log4net.config"));
ExceptionlessClient.Default.RegisterWebApi(GlobalConfiguration.Configuration); }
}
5、logAttribute
public class LogFilterAttribute : ActionFilterAttribute
{
/// <summary>
/// Action执行后
/// </summary>
/// <param name="actionExecutedContext"></param>
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
string url = actionExecutedContext.ActionContext.Request.RequestUri.ToString();
var requestParameters = actionExecutedContext.ActionContext.ActionArguments;
var requestParametersString=Newtonsoft.Json.JsonConvert.SerializeObject(requestParameters);
if (actionExecutedContext.Exception != null)
{
string error = $"Exception:{DateTime.Now}(ㄒoㄒ){url}(ㄒoㄒ){requestParametersString}(ㄒoㄒ){actionExecutedContext.Exception.Message}";
LogHeper.Write(error,LogMessageEnum.Error);
//Exceptionless
ExceptionlessClient.Default.CreateLog(error).Submit();
}
}
}
netframework webapi exceptionless的更多相关文章
- 如何将 .NetFramework WebApi 按业务拆分成多个模块
在 .NetFramework 中使用 WebApi ,在不讨论 微服务 的模式下,大部分都是以层来拆分库的 : 基础设施 数据存储层 服务层 WeApi 层 一些其它的功能库 项目结构可能会像下面这 ...
- netframework webapi IogAttribute记录request参数和错误信息
参考博客 https://www.cnblogs.com/hnsongbiao/p/7039666.html 书写LogFilterAttribute public class LogFilterAt ...
- swagger netframework webapi
参考:https://blog.csdn.net/wjk343977868/article/details/47086137
- 从Owin到System.Web.Http.Owin的HttpMessageHandlerAdapter看适配器模式
.mytitle { background: #2B6695; color: white; font-family: "微软雅黑", "宋体", "黑 ...
- 浅从System.Web.Http.Owin的HttpMessageHandlerAdapter看适配器模式
本文版权归博客园和作者吴双本人共同所有 转载和爬虫请注明原文地址 www.cnblogs.com/tdws 一.写在前面 适配器模式(Adapter) 可用来在现有接口和不兼容的类之间进行适配.有助于 ...
- 混合型log,info按大小分,error按日期
1.配置文件 <?xml version="1.0" encoding="utf-8"?> <configuration> <!- ...
- ExceptionLess的webAPI调用
引用 <package id="bootstrap" version="3.0.0" targetFramework="net461" ...
- C#进阶系列——WebApi 异常处理解决方案
前言:上篇C#进阶系列——WebApi接口传参不再困惑:传参详解介绍了WebApi参数的传递,这篇来看看WebApi里面异常的处理.关于异常处理,作为程序员的我们肯定不陌生,记得在介绍 AOP 的时候 ...
- csc.rsp Nuget MVC/WebAPI、SignalR、Rx、Json、EntityFramework、OAuth、Spatial
# This file contains command-line options that the C# # command line compiler (CSC) will process as ...
随机推荐
- Spring中@Resource与@Autowired、@Qualifier的用法与区别
1.@Autowired与@Resource都可以用来装配bean. 都可以写在字段上,或写在setter方法上. 2.@Autowired默认按类型装配(这个注解是属业spring的),默认情况下必 ...
- [转]谈NAND Flash的底层结构和解析
这里我想以一个纯玩家的角度来谈谈关于NAND Flash的底层结构和解析,可能会有错误的地方,如果有这方面专家强烈欢迎指正. NAND Flash作为一种比较实用的固态硬盘存储介质,有自己的一些物理特 ...
- GoLang之错误处理
错误处理 error Go语言引入了一个错误处理的标准模式,即error接口,该接口定义如下: type error interface { Error() string } 对于大多数函数,如果要返 ...
- Linux系统挂载windows共享目录报错mount error(121):remote error I/O error
经查,这是由于NFS(Network File System)即网络文件系统服务器有多个版本,V2.V3.V4.而且各版本同时运行,因此挂载时需要说明版本号 mount -o username='pk ...
- zookeeper 四字命令的使用
Linux中的命令NetCat有“瑞士军刀”的美誉.我们可以通过nc命令查看Zookeeper的一行属性数据.在Zookeeper中有很多四字命令,汇总如下: 序号 使用命令 输出说明 1 echo ...
- linux如何添加telnet服务
一.安装telnet 1.检测telnet-server的rpm包是否安装 [root@localhost ~]# rpm -qa telnet-server 若无输入内容,则表示没有安装.出于安全考 ...
- python __get__ & __set__
目的: 提供类似java中的getter/setter的东西. (getter/setter的目的: 将属性方法化,使得属性的引用变得简单---尤其将来属性的读取/赋值有比较复杂的逻辑) 官方简明文 ...
- 11.4vue(3)
2018-11-4 20:57:28 越努力越幸运!永远不要高估自己!!!!! 要主动学习!!! 快把vue看完,进行路飞项目!明天整理一下vue知识点!
- codechef cook 103 div2
第一次打codechef...不太会用这oj. A: #include <bits/stdc++.h> #define mk(a,b) make_pair(a,b) #define pii ...
- electron打包后, 使用NSIS再打包成安装包 .exe文件
NSIS下载地址