如何将asp .net core的Exceptionless日志操作优化为高效的长尾词?

2026-03-26 23:451阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计468个文字,预计阅读时间需要2分钟。

如何将asp .net core的Exceptionless日志操作优化为高效的长尾词?

exceptionless官网介绍,使用Nuget包安装,添加引用using Exceptionless; using Exceptionless.Logging; 初始化时设置密钥和请求地址,创建函数初始化日志参数,构造DefaultController类。

exceptionless官网

使用说明

安装Nuget包

添加引用

using Exceptionless; using Exceptionless.Logging;

初始化-秘钥-请求地址

//构造函数 初始化日志参数(日志系统地址,项目模块) public DefaultController() { if (string.IsNullOrWhiteSpace(ExceptionlessClient.Default.Configuration.ApiKey)) { ExceptionlessClient.Default.Configuration.ApiKey = "T2HCNXce3bI7jaPLKhc3ySHyWHZmmE4S2jTaccJV"; ExceptionlessClient.Default.Configuration.ServerUrl = "f250194c02.zicp.vip/"; ExceptionlessClient.Default.Startup(); } }

使用-消息日志

用于记录业务中的请求与返回

/// <summary> /// 中华发票回调接口 /// </summary> /// <returns></returns> [Route("api/Default/ZhInvoiceCallback")] [HttpPost] public HttpResponseMessage ZhInvoiceCallback() { Stream s = System.Web.HttpContext.Current.Request.InputStream; byte[] b = new byte[s.Length]; s.Read(b, 0, (int)s.Length); string postStr = Encoding.GetEncoding("utf-8").GetString(b); //具体使用如下 ExceptionlessClient.Default.CreateLog("中华保险核心接口-发票回调报文", postStr, LogLevel.Info).AddTags("ZhInvoiceCallback").Submit(); }

使用-异常-消息日志LogLevel.Debug

用于记录报错信息,这样去后台查询报错就非常方便,直接看异常面板是否有报错,如果有报错就定位,没有报错就证明程序一切正常

try { await getPz(); } catch (Exception ex) { ExceptionlessClient.Default.CreateLog("SZPZ-YDB.ShenZhenGetRBPZ-异常", $"getPz(),{ex.ToString()}", LogLevel.Debug).Submit(); }

实现案例:

YDB.GeneralSystem.RenBao/ZhouSanLY.cs

$"ZSLY-{ID}-1-CreateOrder-请求"

如何将asp .net core的Exceptionless日志操作优化为高效的长尾词?

ZSLY项目唯一标识{ID}业务主键1-流程环节CreateOrder-日志所在方法-请求/返回

loggerHelper.Info($"ZSLY-{ID}-1-CreateOrder-请求", $"{postJosn}"); var result = await WebRequestHelper.HttpPostTxtAsync(postJosn, $"{Config.AppSettingConfig["ZhouSanLY:CreateOrderUrl"]}?uuid={uuid}"); loggerHelper.Info($"ZSLY-{ID}-1-CreateOrder-返回", $"{result}");

日志后台查询说明

source:SZPZ

message:深圳凭证状态

说明标红部分区分大小写

标签:日志

本文共计468个文字,预计阅读时间需要2分钟。

如何将asp .net core的Exceptionless日志操作优化为高效的长尾词?

exceptionless官网介绍,使用Nuget包安装,添加引用using Exceptionless; using Exceptionless.Logging; 初始化时设置密钥和请求地址,创建函数初始化日志参数,构造DefaultController类。

exceptionless官网

使用说明

安装Nuget包

添加引用

using Exceptionless; using Exceptionless.Logging;

初始化-秘钥-请求地址

//构造函数 初始化日志参数(日志系统地址,项目模块) public DefaultController() { if (string.IsNullOrWhiteSpace(ExceptionlessClient.Default.Configuration.ApiKey)) { ExceptionlessClient.Default.Configuration.ApiKey = "T2HCNXce3bI7jaPLKhc3ySHyWHZmmE4S2jTaccJV"; ExceptionlessClient.Default.Configuration.ServerUrl = "f250194c02.zicp.vip/"; ExceptionlessClient.Default.Startup(); } }

使用-消息日志

用于记录业务中的请求与返回

/// <summary> /// 中华发票回调接口 /// </summary> /// <returns></returns> [Route("api/Default/ZhInvoiceCallback")] [HttpPost] public HttpResponseMessage ZhInvoiceCallback() { Stream s = System.Web.HttpContext.Current.Request.InputStream; byte[] b = new byte[s.Length]; s.Read(b, 0, (int)s.Length); string postStr = Encoding.GetEncoding("utf-8").GetString(b); //具体使用如下 ExceptionlessClient.Default.CreateLog("中华保险核心接口-发票回调报文", postStr, LogLevel.Info).AddTags("ZhInvoiceCallback").Submit(); }

使用-异常-消息日志LogLevel.Debug

用于记录报错信息,这样去后台查询报错就非常方便,直接看异常面板是否有报错,如果有报错就定位,没有报错就证明程序一切正常

try { await getPz(); } catch (Exception ex) { ExceptionlessClient.Default.CreateLog("SZPZ-YDB.ShenZhenGetRBPZ-异常", $"getPz(),{ex.ToString()}", LogLevel.Debug).Submit(); }

实现案例:

YDB.GeneralSystem.RenBao/ZhouSanLY.cs

$"ZSLY-{ID}-1-CreateOrder-请求"

如何将asp .net core的Exceptionless日志操作优化为高效的长尾词?

ZSLY项目唯一标识{ID}业务主键1-流程环节CreateOrder-日志所在方法-请求/返回

loggerHelper.Info($"ZSLY-{ID}-1-CreateOrder-请求", $"{postJosn}"); var result = await WebRequestHelper.HttpPostTxtAsync(postJosn, $"{Config.AppSettingConfig["ZhouSanLY:CreateOrderUrl"]}?uuid={uuid}"); loggerHelper.Info($"ZSLY-{ID}-1-CreateOrder-返回", $"{result}");

日志后台查询说明

source:SZPZ

message:深圳凭证状态

说明标红部分区分大小写

标签:日志