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的更多相关文章

  1. 如何将 .NetFramework WebApi 按业务拆分成多个模块

    在 .NetFramework 中使用 WebApi ,在不讨论 微服务 的模式下,大部分都是以层来拆分库的 : 基础设施 数据存储层 服务层 WeApi 层 一些其它的功能库 项目结构可能会像下面这 ...

  2. netframework webapi IogAttribute记录request参数和错误信息

    参考博客 https://www.cnblogs.com/hnsongbiao/p/7039666.html 书写LogFilterAttribute public class LogFilterAt ...

  3. swagger netframework webapi

    参考:https://blog.csdn.net/wjk343977868/article/details/47086137

  4. 从Owin到System.Web.Http.Owin的HttpMessageHandlerAdapter看适配器模式

    .mytitle { background: #2B6695; color: white; font-family: "微软雅黑", "宋体", "黑 ...

  5. 浅从System.Web.Http.Owin的HttpMessageHandlerAdapter看适配器模式

    本文版权归博客园和作者吴双本人共同所有 转载和爬虫请注明原文地址 www.cnblogs.com/tdws 一.写在前面 适配器模式(Adapter) 可用来在现有接口和不兼容的类之间进行适配.有助于 ...

  6. 混合型log,info按大小分,error按日期

    1.配置文件 <?xml version="1.0" encoding="utf-8"?> <configuration> <!- ...

  7. ExceptionLess的webAPI调用

    引用 <package id="bootstrap" version="3.0.0" targetFramework="net461" ...

  8. C#进阶系列——WebApi 异常处理解决方案

    前言:上篇C#进阶系列——WebApi接口传参不再困惑:传参详解介绍了WebApi参数的传递,这篇来看看WebApi里面异常的处理.关于异常处理,作为程序员的我们肯定不陌生,记得在介绍 AOP 的时候 ...

  9. 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 ...

随机推荐

  1. Oracle分析函数-keep(dense_rank first/last)

    select * from criss_sales where dept_id = 'D02' order by sale_date ; 此时有个新需求,希望查看部门 D02 内,销售记录时间最早,销 ...

  2. MyBatis ResultMap Assocation 返回属性为null的问题

    Model: public class Employee { private Integer id; private String lastName; private String email; pr ...

  3. MyBatis总结五:#{}和${}的用法和区别

    From: https://www.cnblogs.com/blazeZzz/p/9295634.html #{}的用法: 我们发现,在Mapper.xml映射文件中,经常使用#{属性名} 来作为SQ ...

  4. javassist实例

    我们常用到的动态特性主要是反射,在运行时查找对象属性.方法,修改作用域,通过方法名称调用方法等.在线的应用不会频繁使用反射,因为反射的性能开销较大.其实还有一种和反射一样强大的特性,但是开销却很低,它 ...

  5. webpack模块化原理

    https://segmentfault.com/a/1190000010349749     webpack模块化原理-commonjs https://segmentfault.com/a/119 ...

  6. LeetCode - 503. Next Greater Element II

    Given a circular array (the next element of the last element is the first element of the array), pri ...

  7. mysql导出长数字到excel避免显示为科学记数法 解决方法

    经常遇到MYSQL导出长数字或纯数字字符串(如身份证.卡券号.条码.流水号等)到csv或excel文件,用excel打开会显示为科学记数法,甚至后几位转为0.这是由Excel的特性决定的:Excel显 ...

  8. IntelliJ IDEA 2018.3.2无法正常输入字符问题解决方案

    昨天升级IDEA的版本到2018.3.2,今天打开项目发现只要在代码编辑器输入字符(英文.符号或中文等)都会立刻被强制删除,造成一个无法正常输入的现象(回车换行可以).仔细观察这种想象后发有可能是代码 ...

  9. B - Assignment

    Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this com ...

  10. char 与 varchar 区别

    MySQL中的字符串有两个常用的类型:char和varchar,二者各有优势,下面我们来详细分析一下.  转载加补充 在建立数据库表结构的时候,为了给一个String类型的数据定义一个数据库的数据库类 ...