logback 歸檔日志自動壓縮


需要添加依賴 apache-log4j-extras-X.X.X.jar

fileNamePattern 以gz或者zip結尾即可

 

 補充說明:

新生成歸檔gz日志文件,服務器上 vim查看和文本文件沒有區別

可以用gzip -l 查看壓縮率,確實為壓縮文件,grep查不到內容,需要用zgrep

ftp到window機器上用解壓縮軟件可以看到是壓縮文件

 

參考資料:http://logging.apache.org/log4j/extras/apidocs/org/apache/log4j/rolling/TimeBasedRollingPolicy.html

Automatic file compression

TimeBasedRollingPolicy supports automatic file compression. This feature is enabled if the value of the FileNamePattern option ends with .gz or .zip.

 

 

FileNamePattern value Rollover schedule Example
/wombat/foo.%d.gz Daily rollover (at midnight) with automatic GZIP compression of the archived files. During November 23rd, 2004, logging output will go to the file /wombat/foo.2004-11-23. However, at midnight that file will be compressed to become /wombat/foo.2004-11-23.gz. For the 24th of November, logging output will be directed to /wombat/folder/foo.2004-11-24 until its rolled over at the beginning of the next day.

參考資料:https://blog.csdn.net/rootcn/article/details/30237401


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM