Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an appender/configuration for log4j or Logback that allows you to write to a GZIP file?

I'm having issue with logging that is using up too much DiskIO and too much space when a large number of users are using a live system which has issues which only happen in live.

Is there a log4j or (preferably) LogBack appender/configuration that will allow writing directly to a GZIP compressed file?

like image 555
Omar Kooheji Avatar asked Jan 20 '23 12:01

Omar Kooheji


1 Answers

This feature already exists in Logback. Take a look at appenders section, specifically at time based rolling policy.

Quote:

Just like FixedWindowRollingPolicy, TimeBasedRollingPolicy supports automatic file compression. This feature is enabled if the value of the fileNamePattern option ends with .gz or .zip.

Also take a look at time and size based rolling policy.

You can setup rollover to occur after one log file hits a certain limit.

I don't believe writing directly to a GZIP compressed file for every log statement would be feasable, since this would create a pretty big performance overhead. Using a combination of existing features sounds reasonable to me.

like image 57
darioo Avatar answered Apr 29 '23 20:04

darioo