首页天道酬勤log4net日志自动清理,log4j2异步日志配置

log4net日志自动清理,log4j2异步日志配置

admin 06-13 02:47 166次浏览

. net % 20 core % 20 webapi % 20 % E4 % b8 % ad % e9 % 9b % 86 % E6 % 88 % 90 log4net % 20 % E6 % 97 % a5 % E5 % BF % 97 % E8 % af % 84 % E5 % 86 % 86 % 25 % 204.% 20 % E5 % 9c % A8控制器% E4 % b8 % ad % E6 % b5 % E8 % af % 955.% E6 % 97 % a5 % E5 % e9 % E8 % a6 % 20 % E5 % 8f % af % 20 % E5 % 85 % B6 % E5 % 83 % E4 % be % 9d % E8 % b5 % 96 % E7 % 9a % 84 % E5 % 8c CK age % 20 Microsoft.extensions.loons % 20e7% 94 % A8 nu get % E7 % AE % a1 % E7 % 96 % E5 % 99 % A8 % E5 % AE % 89 % E8 % AE ion % 3d % 271.0 % 27 encoding % 3d % 27 utf-8 % 27 % 20 %3flog4% 20c % 8c % E5 % E4 % bb % AC % E7 % 94 % B1 % e9 % 20 type % 3d % 27 log4net.appender.rolling file appender % 27 % 20 param % 20 name % 20 info.log % 27 % 20 % 2f % 20 param % 20 % 20f % 20 param % 20 NAND % 20 % 20 % 20 name % 3d % 27 maxsizerollbackups % 27 % 20 value % 3d % 27100 % 27 % 20 % 20 param % 20 ame % 27 % 20 value % 3d % 27 false % 27 % 20 % 2f % 20 param % 20 name % 3d % 27 date pattern % 27 % 20vv % 20 syle % 27 % 20 value % tern layout % 27 % 20 convert % 20-5 level % 20 % 25 logger % 20-% 20 % 25 message % 25 newline % 27 % 20 % 2f % 20 % 2f layout 7 % 20 % 2f % 20 param % 20 name % 3d % 27 level max % 27 % 20 value % 3d % 27 info % 27 % 20 % 20er % 27 % 20 type % 3d % 27 lolo e % 27 % 20 value 0d % 25 % 20me % 3d % 27 append to file % 27 % 20 value % 27 % 20 % 2f % 20 param % 20 name % 3d % 27 mm 0 param % 20 name % 3d % 27 preservelogfilenameextension % 27 % 20 value % 3d % 2020 value % 3d % 27 false % 27 % 20 % 2f % 20 palue % 27 % 20 % 2f % 2020 % 2f % 20 layout % 20 type % 3d % 27 log4net.layout.pattern layout % 27 % 20转换模式% 20 value t % 20过滤器% 20 type % 3d % 27 log4net.filter.levelrangefilter % 27 % 20pa ager % 202 f % 20 param % 20 name % 3d % 27 level max

r name="errorAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="LogshdsdfsErrorhdsdfsErr.log" /> <param name="AppendToFile" value="true" /> <param name="MaxFileSize" value="10240" /> <param name="MaxSizeRollBackups" value="100" /> <param name="PreserveLogFileNameExtension" value="true" /> <param name="StaticLogFileName" value="false" /> <param name="DatePattern" value="yyyyMMdd" /> <param name="RollingStyle" value="Date" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <param name="LevelMin" value="ERROR" /> <param name="LevelMax" value="ERROR" /> </filter> </appender> <appender name="warnAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="LogshdsdfsWarnhdsdfsWarn.log" /> <param name="AppendToFile" value="true" /> <param name="MaxFileSize" value="10240" /> <param name="MaxSizeRollBackups" value="100" /> <param name="PreserveLogFileNameExtension" value="true" /> <param name="StaticLogFileName" value="false" /> <param name="DatePattern" value="yyyyMMdd" /> <param name="RollingStyle" value="Date" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <param name="LevelMin" value="WARN" /> <param name="LevelMax" value="WARN" /> </filter> </appender> <appender name="fatalAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="LogshdsdfsFatalhdsdfsFatal.log" /> <param name="AppendToFile" value="true" /> <param name="MaxFileSize" value="10240" /> <param name="MaxSizeRollBackups" value="100" /> <param name="PreserveLogFileNameExtension" value="true" /> <param name="StaticLogFileName" value="false" /> <param name="DatePattern" value="yyyyMMdd" /> <param name="RollingStyle" value="Date" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <param name="LevelMin" value="FATAL" /> <param name="LevelMax" value="FATAL" /> </filter> </appender> <root> <level value="ALL" ref="infoAppender" /> <appender-ref ref="infoAppender" /> <appender-ref ref="errorAppender" /> <appender-ref ref="debugAppender" /> <appender-ref ref="warnAppender" /> <appender-ref ref="fatalAppender" /> </root></log4net> 3.在Program中注册Log4Get public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureLogging(logbuilder => { logbuilder.AddFilter("System", LogLevel.Warning); logbuilder.AddFilter("Microsoft", LogLevel.Warning); logbuilder.SetMinimumLevel(LogLevel.Warning); logbuilder.AddLog4Net(); }) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); 4. 在controller中测试 private readonly ILogger<UpdateFilesController> _logger; private readonly IUpdateFiles _updateFiles; public UpdateFilesController(ILogger<UpdateFilesController> logger, IUpdateFiles updateFiles) { _logger = logger; _updateFiles = updateFiles; } /// <summary> /// 获取要更新的版本信息 /// </summary> /// <returns></returns> [HttpGet] public List<FilesInfo> InspectVersion() { return _updateFiles.InspectVersion(); } /// <summary> /// 获取要更新的全部文件信息 /// </summary> /// <param name="version"></param> /// <returns></returns> [HttpGet] public List<FilesInfo> GetUpdateFiles(long version, bool isforce) { _logger.LogInformation("测试日志"); return _updateFiles.GetUpdateFiles(version, isforce); } 5.日志记录结果


可以看到在我们的测试日志就已经记录成功了! 快去实测吧!

SSH的​SpringMVC注解怎么使用element-plus/element-ui跑马灯配备照片及图片自适应的方式
oracle执行sql输出日志,oracle存储过程打印日志 Log4net,vs使用log4net
相关内容