Preamble
Since Furion v3.9.2 has an autonomous and controllable log component, more and more Furion framework users have removed the built-in third-party log component selection framework.The Furion framework provides almost all logging needs required for enterprise development.
This update mainly improves and optimizes log performance, log templates, and log functions.
Highlights of this issue
1. More beautiful log template
[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. Support Visual Studio Code log shrinking, exception log highlighting
3. Provide RabbitMQ event bus usage guide
4. Provide Log static class to write log more functions
// 创建日志对象
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. Provide MessageCenter event bus static class
// 发送消息(含诸多重载)
await MessageCenter.PublishAsync("messageId", new {});
// 动态订阅消息
MessageCenter.Subscribe("messageId", async (ctx) => {
Console.WriteLine("我是动态的");
await Task.CompletedTask;
});
// 取消订阅
MessageCenter.Unsubscribe("messageId");
Update in this issue
new features
- [新增]
AppSettings
configuredExcludeAssemblies
Attribute to support ignoring specified assembly scans 7b7747f- [新增]
Oops.Oh
andOops.Bah
Support setting extra data.WithData(data)
#I5O38E- [新增] timed task
Crontab.GetSleepMilliseconds(baseTime)
Get the time difference of the next occurrence d024fae- [新增] Friendly exceptions print exception logs by default to avoid missing important exception information in the production environment 6e3a5bd
- [新增] log static class
Log.CreateLoggerFactory()
static method 75c672a- [新增] event bus
MessageCenter
static class, resolved fromFur v1.x
Version upgrade problem a29fc7cBreakthrough change
- [新增]
Furion
assemblyPublicKeyToken
strong signature 26b12c0- [调整] event bus
IEventBusFactory
event factory methodAddSubscriber -> Subscribe
,RemoveSubscriber -> Unsubscribe
a29fc7cbug fix
- [修复] Generate contains
中文
ofJWT Token
Garbled code after decryption #I5O397other changes
- [调整] Default output file log template to make it more beautiful #1518cf3
Documentation
- [新增]
RabbitMQ
Event Bus Documentation- [更新]
AppSettings
Configuration documents, event bus documents, multi-database configuration documents, log documents, timed task documents,MessageCenter
Documentation
#NET #Framework #Furion #v434 #Released #Experience #Logging #Module #News Fast Delivery