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 ...
随机推荐
- Linux 文件属性及权限_007
Linux一切皆文件: Llinux系统的文件或目录的属性主要包括:索引节点.文件类型.文件权限.链接数.所属的用户和用户组.最近修改时间等. Llinux文件属性及权限图形说明: Linux文件属性 ...
- VS的ASP.NET项目中cshtml关键词出错 红线,当前上下文中不存在名称
[参考]VS的ASP.NET项目中cshtml突然出错,当前上下文中不存在名称“ViewBag” 原因:web.config 配置错误 这种情况是因为两个web.config文件版本不匹配,需要进行修 ...
- linux环境,通过rpm删除mysql包,报错:error reading information on service mysqld: Invalid argument
问题描述: 今天在做saltstack的练习,想要通过sls的方式,在远程进行mysql数据库的安装,发现无法通过service的方式启动数据库,然后就想给删除了重新进行安装,在通过rpm -e进行删 ...
- CentOS7 安装Python3,开发SocketIO 客户端
CentOS7安装Python3,开发SocketIO 客户端 参考:https://blog.csdn.net/lovefengruoqing/article/details/79284573 步骤 ...
- win PowerCmd命令行工具安装
官网:http://www.powercmd.com/ 下载地址:http://www.powercmd.com/Install_PowerCmd.exe 版本信息: 输入注册码: PowerCmd ...
- 简单工厂模式(Java与Kotlin版)
Kotlin基础知识的学习,请参考之前的文章: Kotlin入门第一课:从对比Java开始 Kotlin入门第二课:集合操作 Kotlin入门第三课:数据类型 初次尝试用Kotlin实现Android ...
- gitlab-ci + k8s 之docker (三)
docker 在本系列(一)中(https://www.cnblogs.com/huandada/p/9965771.html)的runner_tomcat.sh脚本有涉及到镜像的推送,本文主要记录整 ...
- python装饰器语法
@就是decorator,早Python的高效开发中会用到,当然和java的annotation有一定的相似,但又不完全相同,看这篇文章:https://blog.csdn.net/zkp_987/a ...
- Tomb Raider
Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her ...
- array_push() 与 $arr[]=$value 的使用场景
在只压入一个元素的时候使用 $arr[] = $value 当可以同时压入多个元素的时候推荐使用 array_push. 注:如果是压入一个元素,使用$arr[]=$value效率高,因为可以节省调用 ...