過濾掉Abp框架不需要記錄的日誌

来源:https://www.cnblogs.com/AlienXu/archive/2019/09/03/Abp_Log_Filter.html
-Advertisement-
Play Games

該文章是系列文章 "基於.NetCore和ABP框架如何讓Windows服務執行Quartz定時作業" 的其中一篇。 問題 "ABP.WindowsService/Demo.MyJob/4.0.0" 該項目不僅包含了Job服務,還有一個Abp項目自動生成的web站點服務。之前改造了job的日誌記錄, ...


該文章是系列文章 基於.NetCore和ABP框架如何讓Windows服務執行Quartz定時作業 的其中一篇。

問題

ABP.WindowsService/Demo.MyJob/4.0.0該項目不僅包含了Job服務,還有一個Abp項目自動生成的web站點服務。之前改造了job的日誌記錄,之後嘗試改造web站點。發現一個問題,就是每次啟動都會生成類似下文的日誌,但是這些日誌都不是我主動記錄的日誌。那麼顯然,當你試圖記錄日誌,下麵的這些框架自動生成的診斷日誌就會成為干擾。如何去除這些診斷日誌呢?

DEBUG 2019-09-03 18:51:28,556 [1    ] Abp.Modules.AbpModuleManager             - Loading Abp modules...
DEBUG 2019-09-03 18:51:28,928 [1    ] Abp.Modules.AbpModuleManager             - Found 10 ABP modules in total.
DEBUG 2019-09-03 18:51:29,700 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Demo.MyJob.Web.Startup.MyJobWebModule, Demo.MyJob.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,704 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Demo.MyJob.MyJobApplicationModule, Demo.MyJob.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,705 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Demo.MyJob.MyJobCoreModule, Demo.MyJob.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,707 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.AutoMapper.AbpAutoMapperModule, Abp.AutoMapper, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,707 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.AbpKernelModule, Abp, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,707 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Demo.MyJob.EntityFrameworkCore.MyJobEntityFrameworkCoreModule, Demo.MyJob.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,707 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.EntityFrameworkCore.AbpEntityFrameworkCoreModule, Abp.EntityFrameworkCore, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,708 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.EntityFramework.AbpEntityFrameworkCommonModule, Abp.EntityFramework.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,708 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.AspNetCore.AbpAspNetCoreModule, Abp.AspNetCore, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,708 [1    ] Abp.Modules.AbpModuleManager             - Loaded module: Abp.Web.AbpWebCommonModule, Abp.Web.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:29,711 [1    ] Abp.Modules.AbpModuleManager             - 10 modules loaded.
DEBUG 2019-09-03 18:51:30,517 [1    ] ameworkCore.AbpEntityFrameworkCoreModule - Registering DbContext: Demo.MyJob.EntityFrameworkCore.MyJobDbContext, Demo.MyJob.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 18:51:30,912 [1    ] Abp.Localization.LocalizationManager     - Initializing 3 localization sources.
DEBUG 2019-09-03 18:51:31,069 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: Abp
DEBUG 2019-09-03 18:51:31,372 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: MyJob
DEBUG 2019-09-03 18:51:31,419 [1    ] Abp.Localization.LocalizationManager     - Initialized localization source: AbpWeb
DEBUG 2019-09-03 18:51:31,944 [1    ] Abp.BackgroundJobs.BackgroundJobManager  - Start background worker: Castle.Proxies.BackgroundJobManagerProxy
DEBUG 2019-09-03 18:51:32,019 [1    ] Abp.AutoMapper.AbpAutoMapperModule       - Found 0 classes define auto mapping attributes
INFO  2019-09-03 18:51:33,581 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/  
INFO  2019-09-03 18:51:33,581 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 DEBUG http://localhost:62114/  0
INFO  2019-09-03 18:51:33,673 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 90.7012ms 200 
INFO  2019-09-03 18:51:34,194 [7    ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {action = "Index", controller = "Home", area = ""}. Executing action Demo.MyJob.Web.Controllers.HomeController.Index (Demo.MyJob.Web)
INFO  2019-09-03 18:51:34,292 [7    ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method Demo.MyJob.Web.Controllers.HomeController.Index (Demo.MyJob.Web) - Validation state: Valid
INFO  2019-09-03 18:51:34,300 [7    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action method Demo.MyJob.Web.Controllers.HomeController.Index (Demo.MyJob.Web), returned result Microsoft.AspNetCore.Mvc.ViewResult in 5.1007ms.
INFO  2019-09-03 18:51:34,318 [7    ] Abp.Auditing.SimpleLogAuditingStore      - AUDIT LOG: Demo.MyJob.Web.Controllers.HomeController.Index is executed by an anonymous user in 47 ms from ::1 IP address with succeed.
INFO  2019-09-03 18:51:34,395 [7    ] Core.Mvc.ViewFeatures.ViewResultExecutor - Executing ViewResult, running view Index.
INFO  2019-09-03 18:51:34,806 [7    ] Core.Mvc.ViewFeatures.ViewResultExecutor - Executed ViewResult - view Index executed in 468.7549ms.
INFO  2019-09-03 18:51:34,812 [7    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action Demo.MyJob.Web.Controllers.HomeController.Index (Demo.MyJob.Web) in 613.974ms
INFO  2019-09-03 18:51:34,825 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 1250.0712ms 200 text/html; charset=utf-8
INFO  2019-09-03 18:51:34,991 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/sweetalert/dist/sweetalert.css  
INFO  2019-09-03 18:51:34,991 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/toastr/toastr.css  
INFO  2019-09-03 18:51:35,051 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/font-awesome/css/font-awesome.css  
INFO  2019-09-03 18:51:35,085 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/bootstrap-paper/bootstrap.css  
INFO  2019-09-03 18:51:35,109 [6    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/sweetalert/dist/sweetalert.css'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\sweetalert\dist\sweetalert.css'
INFO  2019-09-03 18:51:35,114 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/css/main.css  
INFO  2019-09-03 18:51:35,114 [9    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/font-awesome/css/font-awesome.css'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\font-awesome\css\font-awesome.css'
INFO  2019-09-03 18:51:35,164 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/css/main.css'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\css\main.css'
INFO  2019-09-03 18:51:35,166 [7    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/toastr/toastr.css'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\toastr\toastr.css'
INFO  2019-09-03 18:51:35,169 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 177.5574ms 200 text/css
INFO  2019-09-03 18:51:35,169 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 177.8087ms 200 text/css
INFO  2019-09-03 18:51:35,169 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/famfamfam-flags/dist/sprite/famfamfam-flags.css  
INFO  2019-09-03 18:51:35,169 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 54.5501ms 200 text/css
INFO  2019-09-03 18:51:35,169 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 117.3342ms 200 text/css
INFO  2019-09-03 18:51:35,190 [6    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/famfamfam-flags/dist/sprite/famfamfam-flags.css'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\famfamfam-flags\dist\sprite\famfamfam-flags.css'
INFO  2019-09-03 18:51:35,190 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 20.6735ms 200 text/css
INFO  2019-09-03 18:51:35,257 [7    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/bootstrap-paper/bootstrap.css'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\bootstrap-paper\bootstrap.css'
INFO  2019-09-03 18:51:35,257 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 172.137ms 200 text/css
INFO  2019-09-03 18:51:35,283 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/moment/min/moment-with-locales.js  
INFO  2019-09-03 18:51:35,286 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/json2/json2.js  
INFO  2019-09-03 18:51:35,297 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/jquery-validation/dist/jquery.validate.js  
INFO  2019-09-03 18:51:35,298 [7    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/json2/json2.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\json2\json2.js'
INFO  2019-09-03 18:51:35,300 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 14.5734ms 200 application/javascript
INFO  2019-09-03 18:51:35,300 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/bootstrap/dist/js/bootstrap.js  
INFO  2019-09-03 18:51:35,305 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/jquery/dist/jquery.js  
INFO  2019-09-03 18:51:35,327 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/jquery-validation/dist/jquery.validate.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\jquery-validation\dist\jquery.validate.js'
INFO  2019-09-03 18:51:35,327 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 29.4745ms 200 application/javascript
INFO  2019-09-03 18:51:35,369 [9    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/bootstrap/dist/js/bootstrap.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\bootstrap\dist\js\bootstrap.js'
INFO  2019-09-03 18:51:35,370 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 69.1099ms 200 application/javascript
INFO  2019-09-03 18:51:35,372 [10   ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/toastr/toastr.js  
INFO  2019-09-03 18:51:35,373 [6    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/toastr/toastr.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\toastr\toastr.js'
INFO  2019-09-03 18:51:35,373 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 1.1496ms 200 application/javascript
INFO  2019-09-03 18:51:35,395 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/blockUI/jquery.blockUI.js  
INFO  2019-09-03 18:51:35,400 [10   ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/blockUI/jquery.blockUI.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\blockUI\jquery.blockUI.js'
INFO  2019-09-03 18:51:35,400 [10   ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 4.7696ms 200 application/javascript
INFO  2019-09-03 18:51:35,440 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/sweetalert/dist/sweetalert-dev.js  
INFO  2019-09-03 18:51:35,443 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/spin.js/jquery.spin.js  
INFO  2019-09-03 18:51:35,445 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/spin.js/jquery.spin.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\spin.js\jquery.spin.js'
INFO  2019-09-03 18:51:35,445 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 2.6389ms 200 application/javascript
INFO  2019-09-03 18:51:35,446 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/jquery/dist/jquery.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\jquery\dist\jquery.js'
INFO  2019-09-03 18:51:35,446 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 140.3229ms 200 application/javascript
INFO  2019-09-03 18:51:35,447 [10   ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/spin.js/spin.js  
INFO  2019-09-03 18:51:35,451 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/sweetalert/dist/sweetalert-dev.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\sweetalert\dist\sweetalert-dev.js'
INFO  2019-09-03 18:51:35,451 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 11.1469ms 200 application/javascript
INFO  2019-09-03 18:51:35,521 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/spin.js/spin.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\spin.js\spin.js'
INFO  2019-09-03 18:51:35,521 [10   ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js  
INFO  2019-09-03 18:51:35,521 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 73.7904ms 200 application/javascript
INFO  2019-09-03 18:51:35,521 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js  
INFO  2019-09-03 18:51:35,521 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/abp-web-resources/Abp/Framework/scripts/abp.js  
INFO  2019-09-03 18:51:35,521 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js  
INFO  2019-09-03 18:51:35,522 [10   ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\abp-web-resources\Abp\Framework\scripts\libs\abp.blockUI.js'
INFO  2019-09-03 18:51:35,522 [6    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/abp-web-resources/Abp/Framework/scripts/abp.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\abp-web-resources\Abp\Framework\scripts\abp.js'
INFO  2019-09-03 18:51:35,522 [10   ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 1.7359ms 200 application/javascript
INFO  2019-09-03 18:51:35,523 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 1.4094ms 200 application/javascript
INFO  2019-09-03 18:51:35,525 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\abp-web-resources\Abp\Framework\scripts\libs\abp.toastr.js'
INFO  2019-09-03 18:51:35,525 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 3.6857ms 200 application/javascript
INFO  2019-09-03 18:51:35,526 [7    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\abp-web-resources\Abp\Framework\scripts\libs\abp.jquery.js'
INFO  2019-09-03 18:51:35,526 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 5.0962ms 200 application/javascript
INFO  2019-09-03 18:51:35,555 [9    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/moment/min/moment-with-locales.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\moment\min\moment-with-locales.js'
INFO  2019-09-03 18:51:35,555 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 272.0541ms 200 application/javascript
INFO  2019-09-03 18:51:35,579 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js  
INFO  2019-09-03 18:51:35,589 [9    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\abp-web-resources\Abp\Framework\scripts\libs\abp.sweet-alert.js'
INFO  2019-09-03 18:51:35,589 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 10.0396ms 200 application/javascript
INFO  2019-09-03 18:51:35,589 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/AbpScripts/GetScripts?v=637031334947750684  
INFO  2019-09-03 18:51:35,591 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js  
INFO  2019-09-03 18:51:35,592 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/AbpServiceProxies/GetAll?v=637031334947741174  
INFO  2019-09-03 18:51:35,594 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\abp-web-resources\Abp\Framework\scripts\libs\abp.spin.js'
INFO  2019-09-03 18:51:35,595 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 3.413ms 200 application/javascript
INFO  2019-09-03 18:51:35,597 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/js/views/home/index.js  
INFO  2019-09-03 18:51:35,601 [8    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/js/views/home/index.js'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\js\views\home\index.js'
INFO  2019-09-03 18:51:35,601 [8    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 4.6526ms 200 application/javascript
INFO  2019-09-03 18:51:35,627 [9    ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {action = "GetScripts", controller = "AbpScripts", area = ""}. Executing action Abp.AspNetCore.Mvc.Controllers.AbpScriptsController.GetScripts (Abp.AspNetCore)
INFO  2019-09-03 18:51:35,632 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/famfamfam-flags/dist/sprite/famfamfam-flags.png  
INFO  2019-09-03 18:51:35,633 [6    ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {action = "GetAll", controller = "AbpServiceProxies", area = ""}. Executing action Abp.AspNetCore.Mvc.Proxying.AbpServiceProxiesController.GetAll (Abp.AspNetCore)
INFO  2019-09-03 18:51:35,725 [9    ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method Abp.AspNetCore.Mvc.Controllers.AbpScriptsController.GetScripts (Abp.AspNetCore) with arguments (, False) - Validation state: Valid
INFO  2019-09-03 18:51:35,730 [7    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/famfamfam-flags/dist/sprite/famfamfam-flags.png'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\famfamfam-flags\dist\sprite\famfamfam-flags.png'
INFO  2019-09-03 18:51:35,730 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 97.6549ms 200 image/png
INFO  2019-09-03 18:51:35,787 [6    ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method Abp.AspNetCore.Mvc.Proxying.AbpServiceProxiesController.GetAll (Abp.AspNetCore) with arguments (Abp.AspNetCore.Mvc.Proxying.ApiProxyGenerationModel) - Validation state: Valid
INFO  2019-09-03 18:51:35,789 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/lib/font-awesome/fonts/fontawesome-webfont.woff2?v=4.6.3  
INFO  2019-09-03 18:51:35,819 [7    ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/lib/font-awesome/fonts/fontawesome-webfont.woff2'. Physical path: 'D:\GitHub\DotNetCore_Practice\ABP.WindowsService\Demo.MyJob\4.0.0\src\Demo.MyJob.Web\wwwroot\lib\font-awesome\fonts\fontawesome-webfont.woff2'
INFO  2019-09-03 18:51:35,823 [7    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 33.8363ms 200 font/woff2
INFO  2019-09-03 18:51:35,924 [6    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action method Abp.AspNetCore.Mvc.Proxying.AbpServiceProxiesController.GetAll (Abp.AspNetCore), returned result Microsoft.AspNetCore.Mvc.ContentResult in 135.5736ms.
INFO  2019-09-03 18:51:35,936 [6    ] Mvc.Infrastructure.ContentResultExecutor - Executing ContentResult with HTTP Response ContentType of application/x-javascript
INFO  2019-09-03 18:51:35,937 [6    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action Abp.AspNetCore.Mvc.Proxying.AbpServiceProxiesController.GetAll (Abp.AspNetCore) in 304.1108ms
INFO  2019-09-03 18:51:35,937 [6    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 345.5179ms 200 application/x-javascript
INFO  2019-09-03 18:51:35,982 [9    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action method Abp.AspNetCore.Mvc.Controllers.AbpScriptsController.GetScripts (Abp.AspNetCore), returned result Microsoft.AspNetCore.Mvc.ContentResult in 256.5804ms.
INFO  2019-09-03 18:51:35,982 [9    ] Mvc.Infrastructure.ContentResultExecutor - Executing ContentResult with HTTP Response ContentType of application/x-javascript; charset=utf-8
INFO  2019-09-03 18:51:35,982 [9    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action Abp.AspNetCore.Mvc.Controllers.AbpScriptsController.GetScripts (Abp.AspNetCore) in 354.8506ms
INFO  2019-09-03 18:51:35,982 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 392.9551ms 200 application/x-javascript; charset=utf-8
INFO  2019-09-03 18:51:36,186 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:62114/favicon.ico  
INFO  2019-09-03 18:51:36,189 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 3.4275ms 404 

日誌列印不全

先解決日誌列印不全的問題。
這個問題跟log4net.config有關。

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%-5level %date [%-5.5thread] %-40.40logger - %message%newline" />
    </layout>

%-40.40logger的意思是日誌左對齊,若日誌器的名稱小於 40 個字元,則右邊補空格。若日誌器名稱的長度大於 40 個字元,則截取。更多格式化配置請參考log4net.Layout.PatternLayout 用 conversion 模式格式化日誌事件【翻譯】 - 船長&CAP - 博客園
所以可以將上述配置改為

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%-5level %date [%-5.5thread] %c - %message%newline" />
    </layout>

即只列印出日誌器名稱即可。

日誌過濾

查詢官方文檔 .NET Core 和 ASP.NET Core 中的日誌記錄 | Microsoft Docs
查看源碼 AspNetCore/HostingApplicationDiagnostics.cs at master · aspnet/AspNetCore
看到下述邏輯

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void BeginRequest(HttpContext httpContext, HostingApplication.Context context)
        {
            long startTimestamp = 0;

            if (HostingEventSource.Log.IsEnabled())
            {
                context.EventLogEnabled = true;
                // To keep the hot path short we defer logging in this function to non-inlines
                RecordRequestStartEventLog(httpContext);
            }

            var diagnosticListenerEnabled = _diagnosticListener.IsEnabled();
            var loggingEnabled = _logger.IsEnabled(LogLevel.Critical);

            if (loggingEnabled || (diagnosticListenerEnabled && _diagnosticListener.IsEnabled(ActivityName, httpContext)))
            {
                context.Activity = StartActivity(httpContext, out var hasDiagnosticListener);
                context.HasDiagnosticListener = hasDiagnosticListener;
            }

            if (diagnosticListenerEnabled)
            {
                if (_diagnosticListener.IsEnabled(DeprecatedDiagnosticsBeginRequestKey))
                {
                    startTimestamp = Stopwatch.GetTimestamp();
                    RecordBeginRequestDiagnostics(httpContext, startTimestamp);
                }
            }

            // To avoid allocation, return a null scope if the logger is not on at least to some degree.
            if (loggingEnabled)
            {
                // Scope may be relevant for a different level of logging, so we always create it
                // see: https://github.com/aspnet/Hosting/pull/944
                // Scope can be null if logging is not on.
                context.Scope = _logger.RequestScope(httpContext, context.Activity);

                if (_logger.IsEnabled(LogLevel.Information))
                {
                    if (startTimestamp == 0)
                    {
                        startTimestamp = Stopwatch.GetTimestamp();
                    }

                    // Non-inline
                    LogRequestStarting(context);
                }
            }
            context.StartTimestamp = startTimestamp;
        }

有這樣一行代碼var loggingEnabled = _logger.IsEnabled(LogLevel.Critical);,又文檔 .NET Core 和 ASP.NET Core 中的日誌記錄 | Microsoft Docs中提到

要禁止顯示所有日誌,可將 LogLevel.None 指定為最低日誌級別。 LogLevel.None 的整數值為 6,它大於 LogLevel.Critical (5)。

所以分析之後得出了兩種過濾方案。

官方文檔提供的兩種方案如下。

一種是代碼中進行配置。

改造之前

    public class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
    }

改造之後

    public class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .ConfigureLogging(logging =>
                    logging
                        .AddFilter("System", LogLevel.None)
                        .AddFilter("Microsoft", LogLevel.None)
                    )
                .Build();

            host.Run();
        }
    }

可以看到是ConfigureLogging在起作用,這裡使用LogLevel.None級別,效果如下,只列印出了Abp的審計日誌。

DEBUG 2019-09-03 20:02:21,753 [1    ] Abp.Modules.AbpModuleManager - Loading Abp modules...
DEBUG 2019-09-03 20:02:21,824 [1    ] Abp.Modules.AbpModuleManager - Found 10 ABP modules in total.
DEBUG 2019-09-03 20:02:22,003 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.Web.Startup.MyJobWebModule, Demo.MyJob.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,010 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.MyJobApplicationModule, Demo.MyJob.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,011 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.MyJobCoreModule, Demo.MyJob.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,013 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.AutoMapper.AbpAutoMapperModule, Abp.AutoMapper, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,016 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.AbpKernelModule, Abp, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,018 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.EntityFrameworkCore.MyJobEntityFrameworkCoreModule, Demo.MyJob.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,018 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.EntityFrameworkCore.AbpEntityFrameworkCoreModule, Abp.EntityFrameworkCore, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,019 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.EntityFramework.AbpEntityFrameworkCommonModule, Abp.EntityFramework.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,020 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.AspNetCore.AbpAspNetCoreModule, Abp.AspNetCore, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,021 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.Web.AbpWebCommonModule, Abp.Web.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,024 [1    ] Abp.Modules.AbpModuleManager - 10 modules loaded.
DEBUG 2019-09-03 20:02:22,249 [1    ] Abp.EntityFrameworkCore.AbpEntityFrameworkCoreModule - Registering DbContext: Demo.MyJob.EntityFrameworkCore.MyJobDbContext, Demo.MyJob.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:02:22,457 [1    ] Abp.Localization.LocalizationManager - Initializing 3 localization sources.
DEBUG 2019-09-03 20:02:22,526 [1    ] Abp.Localization.LocalizationManager - Initialized localization source: Abp
DEBUG 2019-09-03 20:02:22,991 [1    ] Abp.Localization.LocalizationManager - Initialized localization source: MyJob
DEBUG 2019-09-03 20:02:23,024 [1    ] Abp.Localization.LocalizationManager - Initialized localization source: AbpWeb
DEBUG 2019-09-03 20:02:23,293 [1    ] Abp.BackgroundJobs.BackgroundJobManager - Start background worker: Castle.Proxies.BackgroundJobManagerProxy
DEBUG 2019-09-03 20:02:23,351 [1    ] Abp.AutoMapper.AbpAutoMapperModule - Found 0 classes define auto mapping attributes
INFO  2019-09-03 20:02:25,645 [6    ] Abp.Auditing.SimpleLogAuditingStore - AUDIT LOG: Demo.MyJob.Web.Controllers.HomeController.Index is executed by an anonymous user in 121 ms from ::1 IP address with succeed.

一種是配置文件指定日誌級別

appsettings.json文件修改之前關於日誌的配置如下

  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  }

日誌指定None級別

  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "None",
      "System": "None",
      "Microsoft": "None"
    }
  }

Web站點添加nuget包 NuGet Gallery | Microsoft.Extensions.Logging.Configuration 2.2.0
修改入口代碼

        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .ConfigureAppConfiguration((hostingContext, config) =>
                {
                    var hostingEnvironment = hostingContext.HostingEnvironment;
                    config.AddJsonFile("appsettings.json", true, true)
                        .AddJsonFile("appsettings." + hostingEnvironment.EnvironmentName + ".json", true, true);
                })
                .ConfigureLogging((hostingContext, logging) =>
                {
                    logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
                })
                .Build();

            host.Run();
        }

如果你的web站點的sdk版本是2.2,可以使用WebHost.CreateDefaultBuilder(),創建預設的WebHostBuilder,該方法預設了上述的配置。源碼請查看 AspNetCore/WebHost.cs at master · aspnet/AspNetCore。該方法在Microsoft.AspNetCore.App中,請引用包 NuGet Gallery | Microsoft.AspNetCore.App 2.2.0

去掉Abp審計日誌

在MyJobWebModule的方法PreInitialize中關閉審計日誌

Configuration.Auditing.IsEnabled = false;

去掉審計日誌之後發現啟動Abp框架的時候還是有日誌記錄下來,日誌內容如下

DEBUG 2019-09-03 20:42:34,063 [1    ] Abp.Modules.AbpModuleManager - Loading Abp modules...
DEBUG 2019-09-03 20:42:34,129 [1    ] Abp.Modules.AbpModuleManager - Found 10 ABP modules in total.
DEBUG 2019-09-03 20:42:34,147 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.Web.Startup.MyJobWebModule, Demo.MyJob.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,170 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.MyJobApplicationModule, Demo.MyJob.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,171 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.MyJobCoreModule, Demo.MyJob.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,172 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.AutoMapper.AbpAutoMapperModule, Abp.AutoMapper, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,173 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.AbpKernelModule, Abp, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,174 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Demo.MyJob.EntityFrameworkCore.MyJobEntityFrameworkCoreModule, Demo.MyJob.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,174 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.EntityFrameworkCore.AbpEntityFrameworkCoreModule, Abp.EntityFrameworkCore, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,175 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.EntityFramework.AbpEntityFrameworkCommonModule, Abp.EntityFramework.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,178 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.AspNetCore.AbpAspNetCoreModule, Abp.AspNetCore, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,179 [1    ] Abp.Modules.AbpModuleManager - Loaded module: Abp.Web.AbpWebCommonModule, Abp.Web.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,185 [1    ] Abp.Modules.AbpModuleManager - 10 modules loaded.
DEBUG 2019-09-03 20:42:34,460 [1    ] Abp.EntityFrameworkCore.AbpEntityFrameworkCoreModule - Registering DbContext: Demo.MyJob.EntityFrameworkCore.MyJobDbContext, Demo.MyJob.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
DEBUG 2019-09-03 20:42:34,704 [1    ] Abp.Localization.LocalizationManager - Initializing 3 localization sources.
DEBUG 2019-09-03 20:42:34,775 [1    ] Abp.Localization.LocalizationManager - Initialized localization source: Abp
DEBUG 2019-09-03 20:42:34,942 [1    ] Abp.Localization.LocalizationManager - Initialized localization source: MyJob
DEBUG 2019-09-03 20:42:34,980 [1    ] Abp.Localization.LocalizationManager - Initialized localization source: AbpWeb
DEBUG 2019-09-03 20:42:35,324 [1    ] Abp.BackgroundJobs.BackgroundJobManager - Start background worker: Castle.Proxies.BackgroundJobManagerProxy
DEBUG 2019-09-03 20:42:35,368 [1    ] Abp.AutoMapper.AbpAutoMapperModule - Found 0 classes define auto mapping attributes

什麼原因導致的呢?分析過程,如下

解決方案:
修改log4net.config配置文件
原配置內容

  <root>
    <level value="DEBUG" />
    <appender-ref ref="RollingFile" />
  </root>

修改為

  <root>
    <level value="INFO" />
    <appender-ref ref="RollingFile" />
  </root>

啟動驗證一下,正常運行之後發現不需要記錄的日誌都已經過濾掉了。


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前言 ArrayList 作為 Java 集合框架中最常用的類,在一般情況下,用它存儲集合數據最適合不過。知其然知其所以然,為了能更好地認識和使用 ArrayList,本文將從下麵幾方面深入理解 ArrayList: 為什麼不用數組,用 ArrayList ArrayList 特性的源碼分析 Jav ...
  • 使用PHP 表單 表單處理: PHP超全局變數:$_GET 和 $ _POST 用於處理表單數據(form data) 表單標簽 ​ action屬性:規定表單數據提交URL ​ method屬性:規定提交時使用的HTTP方法(推薦POST) 表單元素標簽 ​ type屬性:動態定義標簽框的類型 H ...
  • 摘要: 事務在後端開發中無處不在,是數據一致性的最基本保證。要明白進事務的本質就是進到事務切麵的代理方法中,最常見的是同一個類的非事務方法調用一個加了事務註解的方法沒進入事務。我們以 代理為例,由於Spring的對於 代理的實現,進入被代理方法的時候實際上已經離開了“代理這一層殼子”,可以認為代碼走 ...
  • ★簡介 生產者消費者模式並不是GOF提出的23種設計模式之一,23種設計模式都是建立在面向對象的基礎之上的,但其實面向過程的編程中也有很多高效的編程模式,生產者消費者模式便是其中之一,它是我們編程過程中最常用的一種設計模式。 在實際的軟體開發過程中,經常會碰到如下場景:某個模塊負責產生數據,這些數據 ...
  • Ajax在請求controller時會賦值的類型不變,但是返回值,因為會走視圖解析器,所以會以地址的形式進行解析,而不會返回數據,需要在方法上加上註解,將返回類型解析成json類型 一、返回基本類型 @ResponseBody 將返回類型進行解析成json形式 二、返回對象 需要導入jar包 在需要 ...
  • 引言 "原文地址" 在這篇博客中我將探索一些關於Asp.net core 3.0應用的基礎功能——.csproj 項目文件和Program源文件。我將會描述他們從asp.net core 2.X在預設模版中是怎樣改變的,以及探討Aspnetcore3.0使用的Api的變化。 介紹 .Net core ...
  • 網上很多同步教程,按照教程操作upload時一直報錯:sync:invalid gist ID 查找問題很久才知道 gist和token是兩個東西。下麵重新梳理下: 一、下載安裝插件 Setting sync 二、github上生成gist 進入 your gists 隨便給自己的gist起個名,添 ...
  • 場景 實現一個 TextReader,使其以一種特定的編碼從位元組流中讀取字元。 關註公眾號霸道的程式猿獲取編程相關電子書、教程推送與免費下載。 大量編程視頻教程:https://space.bilibili.com/164396311 實現 文本文件讀取 新建命令視窗程式。 在main方法中: 在上 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...