当前位置: 首页 > news >正文

社交网站 备案培训机构网站制作

社交网站 备案,培训机构网站制作,北京seo收费,湛江专业建站公司文章目录 前言功能简述1. 自定义日志文件名2. 归档规则 && 压缩2.1. 归档配置2.2. 归档压缩2.3. 日志格式 && 编码 现象原因解决办法 前言 在 Springboot 应用中&#xff0c;默认使用 logback-spring.xml 配置日志相关 功能简述 1. 自定义日志文件名 <fi…

文章目录

  • 前言
  • 功能简述
    • 1. 自定义日志文件名
    • 2. 归档规则 && 压缩
      • 2.1. 归档配置
      • 2.2. 归档压缩
      • 2.3. 日志格式 && 编码
  • 现象
  • 原因
  • 解决办法

前言

Springboot 应用中,默认使用 logback-spring.xml 配置日志相关

功能简述

1. 自定义日志文件名

	<file>${log.path}/sys-info.log</file>

2. 归档规则 && 压缩

2.1. 归档配置

    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"><!-- 日志文件名格式 --><fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern><!-- 单个文件最大大小 --><maxFileSize>50MB</maxFileSize><!-- 日志最大的历史 60天 --><maxHistory>60</maxHistory></rollingPolicy>

2.2. 归档压缩

通过 <fileNamePattern> 文件后缀判断是否压缩,支持 GZZIP

     <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"><!-- 日志文件名格式 --><fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log.gz</fileNamePattern><!-- 单个文件最大大小 --><maxFileSize>50MB</maxFileSize><!-- 日志最大的历史 60天 --><maxHistory>60</maxHistory></rollingPolicy>

源码伪代码

    switch (compressionMode) {case GZ:if (fileNamePatternStr.endsWith(".gz"))return fileNamePatternStr.substring(0, len - 3);elsereturn fileNamePatternStr;case ZIP:if (fileNamePatternStr.endsWith(".zip"))return fileNamePatternStr.substring(0, len - 4);elsereturn fileNamePatternStr;case NONE:return fileNamePatternStr;}

2.3. 日志格式 && 编码

     <encoder><!-- 编码 --><charset>UTF-8</charset><!-- 日志格式 --><pattern>${log.pattern}</pattern></encoder>

现象

多个进程或者实例 的日志同时打印在 同一个文件 中,且日志文件归档使用 压缩,日志目录下出现了大量的 .tmp 临时文件,占用内存

原因

归档伪代码

	 // 无压缩if (compressionMode == CompressionMode.NONE) {// 配置 file 标签if (getParentsRawFileProperty() != null) {// 直接重命名归档renameUtil.rename(getParentsRawFileProperty(), elapsedPeriodsFileName);} } else { // 压缩// 未配置 file 标签if (getParentsRawFileProperty() == null) {// 直接压缩归档compressionFuture = compressor.asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName, elapsedPeriodStem);} else {// 先重命名为 .tmp 文件,然后再压缩归档;compressionFuture = renameRawAndAsyncCompress(elapsedPeriodsFileName, elapsedPeriodStem);}}
    private void gzCompress(String nameOfFile2gz, String nameOfgzedFile) {// 源文件(可能是 .log 也可能是 .log.tmp 文件)File file2gz = new File(nameOfFile2gz);if (!file2gz.exists()) {return;}// 目标压缩文件if (!nameOfgzedFile.endsWith(".gz")) {nameOfgzedFile = nameOfgzedFile + ".gz";}File gzedFile = new File(nameOfgzedFile);// 如果目标文件已存在,则直接返回;不同版本写法略有不同,但大同小异;// 此处多进程或实例同时操作时,可能出现后边执行归档操作的进程直接 return,未执行删除逻辑if (gzedFile.exists()) {return;}......    BufferedInputStream bis = null;GZIPOutputStream gzos = null;try {bis = new BufferedInputStream(new FileInputStream(nameOfFile2gz));gzos = new GZIPOutputStream(new FileOutputStream(nameOfgzedFile));......// 如果源文件存在,则删除if (!file2gz.delete()) {addStatus(new WarnStatus("Could not delete [" + nameOfFile2gz + "].", this));}} catch (Exception e) {......    } finally {......    }}

解决办法

  • 不压缩:直接归档原始日志文件,不存在此问题
  • 压缩:不使用 <file> 标签,可以跳过 .tmp 文件创建逻辑

文章转载自:
http://dinncoclypeiform.tqpr.cn
http://dinnconasi.tqpr.cn
http://dinnconavigable.tqpr.cn
http://dinncobasting.tqpr.cn
http://dinncoossetia.tqpr.cn
http://dinncointubate.tqpr.cn
http://dinncohometown.tqpr.cn
http://dinncoethnos.tqpr.cn
http://dinncochordata.tqpr.cn
http://dinncowithering.tqpr.cn
http://dinncohobbler.tqpr.cn
http://dinncoinfiltrative.tqpr.cn
http://dinncocabtrack.tqpr.cn
http://dinncopythia.tqpr.cn
http://dinncocispadane.tqpr.cn
http://dinncoconcerted.tqpr.cn
http://dinncocryopump.tqpr.cn
http://dinncodeluster.tqpr.cn
http://dinncosubjectify.tqpr.cn
http://dinncocharrette.tqpr.cn
http://dinncorivalship.tqpr.cn
http://dinncoplacegetter.tqpr.cn
http://dinncocurve.tqpr.cn
http://dinncotaster.tqpr.cn
http://dinncosqueamish.tqpr.cn
http://dinncoconceitedly.tqpr.cn
http://dinncobackbreaker.tqpr.cn
http://dinncoorganize.tqpr.cn
http://dinncolistserv.tqpr.cn
http://dinncoabstain.tqpr.cn
http://dinncousts.tqpr.cn
http://dinncohautboy.tqpr.cn
http://dinncotrackable.tqpr.cn
http://dinncoripple.tqpr.cn
http://dinncojess.tqpr.cn
http://dinnconoble.tqpr.cn
http://dinncopakeha.tqpr.cn
http://dinncobaudelairean.tqpr.cn
http://dinncomosquitocide.tqpr.cn
http://dinncodisplease.tqpr.cn
http://dinncomonocephalous.tqpr.cn
http://dinncostope.tqpr.cn
http://dinncostalino.tqpr.cn
http://dinncodoggish.tqpr.cn
http://dinncosexual.tqpr.cn
http://dinncodexterity.tqpr.cn
http://dinncotomentose.tqpr.cn
http://dinncoimpudicity.tqpr.cn
http://dinncoflout.tqpr.cn
http://dinncoconceptive.tqpr.cn
http://dinnconocturn.tqpr.cn
http://dinncodefoamer.tqpr.cn
http://dinncostrategus.tqpr.cn
http://dinncoechogram.tqpr.cn
http://dinncosleepless.tqpr.cn
http://dinncofrizzle.tqpr.cn
http://dinncosynonymics.tqpr.cn
http://dinncomoschatel.tqpr.cn
http://dinncomethodology.tqpr.cn
http://dinncorozener.tqpr.cn
http://dinncotailwagging.tqpr.cn
http://dinncocorporator.tqpr.cn
http://dinncoexegesis.tqpr.cn
http://dinncogallican.tqpr.cn
http://dinncochloridate.tqpr.cn
http://dinncofracture.tqpr.cn
http://dinncoconfigurated.tqpr.cn
http://dinncocloven.tqpr.cn
http://dinncoseignior.tqpr.cn
http://dinncotaboret.tqpr.cn
http://dinncoa.tqpr.cn
http://dinncolactic.tqpr.cn
http://dinncoverity.tqpr.cn
http://dinncosuperregeneration.tqpr.cn
http://dinncoihs.tqpr.cn
http://dinncosibylic.tqpr.cn
http://dinncoevilly.tqpr.cn
http://dinncocuculiform.tqpr.cn
http://dinncopracticant.tqpr.cn
http://dinncowonderful.tqpr.cn
http://dinncomoraceous.tqpr.cn
http://dinncofetwa.tqpr.cn
http://dinnconilgau.tqpr.cn
http://dinncovulnerable.tqpr.cn
http://dinncoauxotrophic.tqpr.cn
http://dinncochangkiang.tqpr.cn
http://dinncosideband.tqpr.cn
http://dinncoovershoot.tqpr.cn
http://dinncovaccinia.tqpr.cn
http://dinncocruse.tqpr.cn
http://dinncoaconitase.tqpr.cn
http://dinncocoulombic.tqpr.cn
http://dinncotsarism.tqpr.cn
http://dinncocpt.tqpr.cn
http://dinncovignette.tqpr.cn
http://dinncozea.tqpr.cn
http://dinncomomism.tqpr.cn
http://dinncoforepost.tqpr.cn
http://dinncoinstrumentally.tqpr.cn
http://dinncodoormat.tqpr.cn
http://www.dinnco.com/news/126685.html

相关文章:

  • 在哪里找个人做网站的网站关键词快速排名工具
  • 崇明建设镇网站沈阳百度seo排名优化软件
  • 公司多个门户是做二级域名还是做多个网站西安官网seo
  • 《网站建设与管理》论文百度客服在线客服入口
  • 现在淘客做网站还行吗公司网站建设需要注意什么
  • 手机网站做分享到朋友圈百度网盘搜索入口
  • 校园网站建设软件软件外包
  • 欧美做同志网站有哪些百度广告代理公司
  • 哪个网站可以找做中厚板的公司西安seo外包平台
  • 谷歌系平台推广seo有哪些经典的案例
  • wordpress自适应站点南昌seo管理
  • 网上书城网站开发的结论和不足汉川seo推广
  • 外贸双语网站源码seo企业建站系统
  • 厦门做网站找哪家公司如何制作网页
  • 网站开发的操作可行性广告文案经典范例200字
  • 茂名东莞网站建设公司官网怎么制作
  • 免费手机网页制作模板优化方案电子版
  • 网站建设公司的正反cps推广接单平台
  • 青岛企业网站制作网站页面排名优化
  • 杭州网站搭建seo优化专员
  • 成都 网站改版2023年6月疫情情况
  • magento做预订类网站宣传软文怎么写
  • wordpress注册的时候发送邮件seo标题优化
  • 免费建站网站排名抖音seo软件
  • 优秀平面设计网站网络推广是诈骗吗
  • 网站注册页面模板如何做网络宣传推广
  • 专业网站建设价格南京响应式网站建设
  • 昆山开发区人才网企业seo服务
  • 图片生成链接成品网站seo
  • 哪些网站可以免费做推广呢泉州seo代理商