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

I have a problem with logging that uses too much DiskIO and too much space when a large number of users use a live system that has problems that occur only in real time.

Is there a log4j or (preferably) a LogBack application / configuration that allows writing directly to a compressed gzip file?

+4
source share
2 answers

This feature already exists in the log. Take a look at the appenders section, in particular the time-based policies .

Quote:

Like FixedWindowRollingPolicy , TimeBasedRollingPolicy supports automatic file compression. This function is activated if the value of the fileNamePattern parameter ends with .gz or .zip .

Also take a look at calendar policies based on time and size .

You can configure rollovers after one log file reaches a certain limit.

I do not believe that writing directly to a compressed GZIP file for each log statement would be feasible, since it would create quite a lot of overhead. Using a combination of existing features sounds reasonable to me.

+8
source

The space problem has already been resolved with logback. It will compress your log files during rollover. The I / O problem is completely different, and I'm afraid that logback does not offer a solution.

+1
source

Source: https://habr.com/ru/post/1339350/


All Articles