Note: see associated StackOverflow problem
Currently our `RollingFileAppender` in `log4j2.xml` uses Gzip compression:
I would like to switch to LZMA(2) (i.e. .xz) compression, to enjoy an improved compression ratio.
I have tried changing engine.log.%i.gz to engine.log.%i.xz — as per the documentation:
If the file pattern ends with .gz, .zip, .bz2, .deflate, .pack200, or .xz the resulting archive will be compressed using the compression scheme that matches the suffix. The formats bzip2, Deflate, Pack200 and XZ require Apache Commons Compress. In addition, XZ requires XZ for Java.
Additionally I have ensured that I have a runtime dependency on XZ for Java — via pom.xml:
When the RollingFileAppender is triggered: the archive created is indeed named engines.log.1.xz — as required.
However, its contents are incorrect:
engines.log.1.xz should contain LZMA(2) compressed text
engines.log.1.xz instead contains plain, uncompressed text.
I confirm that the org.tukaani:xz and org.apache.commons:commons-compress successfully made it into the classpath of my jar:
This Java program is not deployed to a J2EE webserver. I believe its class loading is straightforward.
I have correctly followed the instructions necessary to create .gz archives.
I believe the only additional step required to create .xz archives is: I must provide at runtime the XZ for Java artefact. I have done this.
Am I missing something here? I am tempted to believe one of the following:
- The functionality is broken
- The docs are incomplete/incorrect
- log4j2 fails to discover the class at runtime
I was able to find some evidence that perhaps I am expected to input .xy instead of .xz. If I use .xy: the log4j2 RollingAppender fails to produce archives. That is: it creates blank .xy files, and retains the unarchived plaintext as a .log file. It smells like a buggy implementation.
Here is the code I present as evidence from org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy: