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. sql 时间转换格式 convert(varchar(10),字段名,转换格式)

    convert(varchar(10),字段名,转换格式) CONVERT(nvarchar(10),count_time,121) CONVERT为日期转换函数,一般就是在时间类型(datetime ...

  2. 多级分类标签{dede:channelartlist}实现当前栏目颜色高亮显示

    我们知道,如果要在网站上多级分类显示的话,可以用下面的标签实现:   {dede:channelartlist typeid='4' cacheid='channelsonlist'}    < ...

  3. adsas数据库去O记

    adsas 数据库是用于广告买量数据分析;在17年由 Oracle 迁移到 PostgreSQL.现把之前的迁移笔记整理下.本次迁移表91个:存储过程21个:数据库大小2G. 1. 准备Postgre ...

  4. linux 使用不安全的sprintf函数,存储字符越界导致程序莫名崩溃问题

    linux c++编程 问题背景: 在处理一个公共模块的代码中,其中有以下代码片段 //代码片段-组合一组字符串并存放到szSignKey数组中 ] = {}; sprintf(szSignKey, ...

  5. Docker学习笔记之二:制作镜像并PUSH

    Pull 如果是Public的(docker官方仓库和加速器) 直接 docker pull ubuntu:16.04 即可 若是私有的 首先登陆 docker login 仓库Host 之后 doc ...

  6. E - Stones 优先队列

    来源1896 Because of the wrong status of the bicycle, Sempr begin to walk east to west every morning an ...

  7. 查看集成环境 phpstudy 中 mysql 版本号

    1. 打开面板 2.其他选项菜单 3. Mysql工具 4. mysql命令行 5.输入密码,回车.phpstudy  mysql默认 root 6.运行 select    version();

  8. thymeleaf(一)

    (一)Thymeleaf 是个什么?      简单说, Thymeleaf 是一个跟 Velocity.FreeMarker 类似的模板引擎,它可以完全替代 JSP .相较与其他的模板引擎,它有如下 ...

  9. mac homebrew

    brew 全称Homebrew  是Mac OSX上的软件包管理工具 Homebrew 安装和卸载工具 只用一行命令就能完成 官方地址:    http://brew.sh/index.html   ...

  10. 原生js的remove方法代表删除节点

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...