性能文章>.NET 框架 Furion v4.3.4 发布,日志模块全新体验>

.NET 框架 Furion v4.3.4 发布,日志模块全新体验原创

https://a.perfma.net/img/3110416
2年前
303901

序言

自 Furion v3.9.2 版本有了自主可控的日志组件之后,越来越多的 Furion 框架使用者移除了第三方日志组件选择框架内置的,Furion 框架提供了企业开发所需的几乎所有日志需求。

本期更新主要对日志性能,日志模板,日志功能进行了改进优化。

仓库地址:https://gitee.com/dotnetchina/Furion
文档地址:https://dotnetchina.gitee.io/furion/

259E5D4D-8E7D-4743-8ECA-207E85DC9F48.png

249E9571-71B2-41F9-AFA1-FE4A9C8A610B.png

本期亮点

1.  更加美观的日志模板

[INF] [Microsoft.Hosting.Lifetime] 2022-08-30T15:52:13.7033488+08:00 [ListeningOnAddress] 
      Now listening on: https://localhost:5001
[INF] [Microsoft.Hosting.Lifetime] 2022-08-30T15:52:13.7405477+08:00 [0] 
      Application started. Press Ctrl+C to shut down.
[INF] [Microsoft.Hosting.Lifetime] 2022-08-30T15:52:13.7453185+08:00 [0] 
      Hosting environment: Development
[INF] [Microsoft.Hosting.Lifetime] 2022-08-30T15:52:13.7482401+08:00 [0] 
      Content root path: D:\Workplaces\OpenSources\Furion\samples\Furion.Web.Entry\
[WRN] [Furion.Application.TestLoggerServices] 2022-08-30T15:52:32.3892150+08:00 [0] 
      我是一个二配置日志 20
[ERR] [Furion.Application.TestLoggerServices] 2022-08-30T15:52:35.1479371+08:00 [0] 
      测试日志异常      
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      System.Exception: 错误啦
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[INF] [System.Logging.LoggingMonitor] 2022-08-30T15:53:26.3936806+08:00 [0] 
      ┏━━━━━━━━━━━  Logging Monitor ━━━━━━━━━━━
      ┣ Furion.Application.TestLoggerServices.GetPerson (Furion.Application)
      ┣ 
      ┣ 控制器名称:          TestLoggerServices
      ┣ 操作名称:            GetPerson
      ┣ 路由信息:            [area]: ; [controller]: test-logger; [action]: person
      ┣ 请求方式:            GET
      ┣ 请求地址:            https://localhost:5001/api/test-logger/person/233
      ┣ 来源地址:            https://localhost:5001/api/index.html
      ┣ 浏览器标识:          Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70
      ┣ 客户端 IP 地址:      0.0.0.1
      ┣ 服务端 IP 地址:      0.0.0.1
      ┣ 服务端运行环境:      Development
      ┣ 执行耗时:            56ms
      ┣ ━━━━━━━━━━━━━━━  参数列表 ━━━━━━━━━━━━━━━
      ┣ Content-Type:        
      ┣ 
      ┣ id (Int32):          233
      ┣ ━━━━━━━━━━━━━━━  返回信息 ━━━━━━━━━━━━━━━
      ┣ 原始类型:            Furion.Application.Persons.PersonDto
      ┣ 最终类型:            Furion.UnifyResult.RESTfulResult`1[[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
      ┣ 最终返回值:          {"StatusCode":200,"Data":{"Id":233,"Name":null,"Age":0,"Address":null,"PhoneNumber":null,"QQ":null,"CreatedTime":"0001-01-01T00:00:00+00:00","Childrens":null,"Posts":null},"Succeeded":true,"Errors":null,"Extras":null,"Timestamp":1661846006385}
      ┗━━━━━━━━━━━  Logging Monitor ━━━━━━━━━━━
[ERR] [System.Logging.FriendlyException] 2022-08-30T15:53:33.0839966+08:00 [0] 
      Attempted to divide by zero.      
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      System.DivideByZeroException: Attempted to divide by zero.
         at Furion.Application.TestLoggerServices.测试直接抛出异常拦截(Int32 id) in D:\Workplaces\OpenSources\Furion\samples\Furion.Application\TestLoggerServices.cs:line 92
         at lambda_method108(Closure , Object , Object[] )
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[INF] [Microsoft.EntityFrameworkCore.Database.Command] 2022-08-30T15:53:44.1172386+08:00 [Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted] 
      Executed DbCommand (53ms) [Parameters=[@__p_0='1'], CommandType='Text', CommandTimeout='30']
      SELECT "p"."Id", "p"."Address", "p"."Age", "p"."CreatedTime", "p"."Name", "p"."UpdatedTime"
      FROM "Person" AS "p"
      WHERE "p"."Id" = @__p_0
      LIMIT 1
[WRN] [Microsoft.EntityFrameworkCore.Query] 2022-08-30T15:53:49.0965317+08:00 [Microsoft.EntityFrameworkCore.Query.MultipleCollectionIncludeWarning] 
      Compiling a query which loads related collections for more than one collection navigation, either via 'Include' or through projection, but no 'QuerySplittingBehavior' has been configured. By default, Entity Framework will use 'QuerySplittingBehavior.SingleQuery', which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call 'ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))'.
[INF] [Microsoft.EntityFrameworkCore.Database.Command] 2022-08-30T15:53:49.1180132+08:00 [Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted] 
      Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT "p"."Id", "p"."Name", "p"."Age", "p"."Address", "p0"."PhoneNumber", "p0"."QQ", "p"."CreatedTime", "p0"."Id", "c"."Id", "c"."Name", "c"."Gender", "t"."Id", "t"."Name", "t"."PersonsId", "t"."PostsId"
      FROM "Person" AS "p"
      LEFT JOIN "PersonDetail" AS "p0" ON "p"."Id" = "p0"."PersonId"
      LEFT JOIN "Children" AS "c" ON "p"."Id" = "c"."PersonId"
      LEFT JOIN (
          SELECT "p2"."Id", "p2"."Name", "p1"."PersonsId", "p1"."PostsId"
          FROM "PersonPost" AS "p1"
          INNER JOIN "Post" AS "p2" ON "p1"."PostsId" = "p2"."Id"
      ) AS "t" ON "p"."Id" = "t"."PersonsId"
      ORDER BY "p"."Id", "p0"."Id", "c"."Id", "t"."PersonsId", "t"."PostsId"

49754D71-EA8E-4BC3-B2A7-B54649C871C3.png

2. 支持 Visual Studio Code 日志收缩、异常日志高亮

56893AFF-42FC-4A0E-BFBE-DF0DB21104D9.png

F0D879AB-F766-4D41-B030-B15975DAC417.png

3. 提供 RabbitMQ 事件总线使用指南

6F48836C-9714-4DC5-B1FC-DFB0A1B189AA.png

4. 提供 Log 静态类写日志更多功能

// 创建日志对象
var logger = Log.CreateLogger("日志名称");

// 创建日志工厂
using var loggerFactory = Log.CreateLoggerFactory(builder => {
    // ....
});

// 日志记录
Log.Information("Information");
Log.Warning("Warning");
Log.Error("Error");
Log.Debug("Debug");
Log.Trace("Trace");
Log.Critical("Critical");


5. 提供 MessageCenter 事件总线静态类

// 发送消息(含诸多重载)
await MessageCenter.PublishAsync("messageId", new {});

// 动态订阅消息
MessageCenter.Subscribe("messageId", async (ctx) => {
    Console.WriteLine("我是动态的");
    await Task.CompletedTask;
});

// 取消订阅
MessageCenter.Unsubscribe("messageId");

本期更新

新特性

[新增] AppSettings 配置的 ExcludeAssemblies 属性,支持忽略指定程序集扫描 7b7747f
[新增] Oops.Oh 和 Oops.Bah 支持设置额外数据 .WithData(data) #I5O38E
[新增] 定时任务 Crontab.GetSleepMilliseconds(baseTime) 获取下一个发生时间的时间差 d024fae
[新增] 友好异常默认打印异常日志,避免生产环境漏掉重要异常信息 6e3a5bd
[新增] 日志静态类 Log.CreateLoggerFactory() 静态方法 75c672a
[新增] 事件总线 MessageCenter 静态类,解决从 Fur v1.x 版本升级问题 a29fc7c
突破性变化

[新增] Furion 程序集 PublicKeyToken 强签名 26b12c0
[调整] 事件总线 IEventBusFactory 事件工厂方法 AddSubscriber -> Subscribe,RemoveSubscriber -> Unsubscribe a29fc7c
问题修复

[修复] 生成包含 中文 的 JWT Token 解密后出现乱码问题 #I5O397
其他更改

[调整] 默认输出文件日志模板,使其更加美观 #1518cf3
文档

[新增] RabbitMQ 事件总线文档
[更新] AppSettings 配置文档、事件总线文档、多数据库配置文档、日志文档、定时任务文档、MessageCenter 文档

点赞收藏
堆堆

【HeapDump性能社区官方小编】各位堆友们,+微信号perfMa,可以联系上堆堆哦~

请先登录,感受更多精彩内容
快去登录吧,你将获得
  • 浏览更多精彩评论
  • 和开发者讨论交流,共同进步
1
0
https://a.perfma.net/img/3110416
堆堆

徽章

【HeapDump性能社区官方小编】各位堆友们,+微信号perfMa,可以联系上堆堆哦~