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 ...
随机推荐
- 苹果应用商店逾千款iOS应用存安全漏洞
据国外网站Ibtimes报道,知名网络安全公司FireEye日前警告称,由于一款名为“JSPatch”.可帮助开发者修改应用程序的软件上存在安全漏洞,导致苹果应用商店内1000多款使用了该框架的iOS ...
- Linux iptables原理和使用
1.原理 iptables简介 netfilter/iptables(简称为iptables)组成Linux平台下的包过滤防火墙,与大多数的Linux软件一样,这个包过滤防火墙是免费的,它可以代替昂贵 ...
- shell md5sum
md5sum out.a echo "fd_limit=$(ulimit -n), fd_used=$(ll /proc/4741/fd | wc -l)" 需找句柄,及fd ...
- return在try...except...finally...中的表现
一直以为return就直接退出函数了,最近遇到一情况,在try中return,并没有什么卵用,还是会去执行finally里的内容,导致不能正确返回想要的数据 一直以为return就会跳出函数,发现原来 ...
- dubbo RPC超时异常小结
dubbo消费者调用服务超时的原因可能有很多,今天排查问题花了两个小时,也查了很多资料,好像每一篇资料都是提出一个问题,所以简单总结几点: 1. 配置才是重中之重,仔细检查服务提供方的dubbo se ...
- ZOJ 3886 Nico Number(筛素数+Love(线)Live(段)树)
problemCode=3886">ZOJ 3886 题意: 定义一种NicoNico数x,x有下面特征: 全部不大于x且与x互质的数成等差数列,如x = 5 ,与5互素且不大于5的数 ...
- CentOS安装和配置Apache(httpd)
1. 安装httpd yum install httpd #安装apache 2. 启动httpd systemctl start httpd.service #启动apache 3. 随服务器自启动 ...
- [原]unity5 AssetBundle 加载
本文unity版本5.1.3 一.现有的打包教程: 1.http://liweizhaolili.blog.163.com/blog/static/16230744201541410275298/ 阿 ...
- MySql 查询银行卡号打码
),")) end as card_number from das.staff_base; case 函数 CASE WHEN 条件1 THEN 结果1 WHEN 条件2 THE ...
- 【Android Studio】Gradle配置及问题解决
Error:Failed to open zip file.Gradle's dependency cache may be corrupt (this sometimes occurs after ...