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

序言

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

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

本期亮点

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"

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

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

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 -> SubscribeRemoveSubscriber -> Unsubscribe a29fc7c
  • 问题修复

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

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

    • [新增] RabbitMQ 事件总线文档
    • [更新] AppSettings 配置文档、事件总线文档、多数据库配置文档、日志文档、定时任务文档、MessageCenter 文档
优秀的个人博客,低调大师

微信关注我们

原文链接:https://www.oschina.net/news/208530/furion-4-3-4-released

转载内容版权归作者及来源网站所有!

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

相关文章

发表评论

资源下载

更多资源
优质分享Android(本站安卓app)

优质分享Android(本站安卓app)

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario,低调大师唯一一个Java游戏作品

Mario,低调大师唯一一个Java游戏作品

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Apache Tomcat7、8、9(Java Web服务器)

Apache Tomcat7、8、9(Java Web服务器)

Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。

Sublime Text 一个代码编辑器

Sublime Text 一个代码编辑器

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。