You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2024/09/05 18:23:22 UTC

[PR] Move compression into new `log4j-compress` module (logging-log4j2)

ppkarwasz opened a new pull request, #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921

   We move the code that depends on Commons Compress
   into a new `log4j-compress` module.
   
   At the same time, we perform the following behavioral changes:
   
   - Compression is performed by the `CompressActionFactoryProvider`, with the maximum order. In the current setting, if `log4j-compress` is on the classpath, it is used for everything, even GZ and ZIP.
   - The `compressionLevel` parameter, specific to the GZ and ZIP compression factories in the JRE, is replaced by a more generic `compressionOptions` map. This will allow adding more compression options in the future if users request it.
   - The available list of compression algorithms is no longer hardcoded, but depends entirely on the list of compressors supported by Apache Commons Compress.
   
   > [!NOTE]
   > Currently Commons Compress does not offer an algorithm-independent
   > interface to supply additional compression options. However, each algorithm does provide such a way.
   > If there are requests from users to support these options, we can extend the `RolloverStrategy` implementations.
   > Until that happens I am reluctant to add additional features.
   
   ## Review guide
   
   The main change revolves around the replacement of `FileExtension` with 2 new interfaces:
   
   * `CompressActionFactory`: this class inherits the **instance** methods from `FileExtension` and allows to create lambdas that compress files.
   * `CompressActionFactoryProvider`: a new Log4j plugin type that can be used to register new compression algorithms. In practice there are two implementations (one for the algos in the JRE and one for Apache Commons Compress). All the remaining compression algorithms should extend Commons Compress.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757403120


##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>

Review Comment:
   Maybe it would be prudent, but I would prefer 3rd party compression libraries to integrate with Commons Compress instead of us. I did add a custom `CompressorStreamProvider` to prove that 3rd party extensions to Commons Compress can be used by this module.
   
   While writing this PR I also looked if we can integrate [CLP](https://github.com/y-scope/clp) through this mechanism. The answer is no: CLP would require us to compress each log event separately, it is not useful to compress already written log files (at least without parsing them again).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757433444


##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>
+  <name>Apache Log4j Core: Extended Compression Support</name>
+  <description>Add additional compression formats to Log4j Core.</description>
+
+  <properties>
+    <commons-compress.version>1.27.1</commons-compress.version>
+    <jimfs.version>1.3.0</jimfs.version>
+    <xz.version>1.10</xz.version>
+    <zstd.version>1.5.6-5</zstd.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>${commons-compress.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.google.jimfs</groupId>
+        <artifactId>jimfs</artifactId>
+        <version>${jimfs.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.tukaani</groupId>
+        <artifactId>xz</artifactId>
+        <version>${xz.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.github.luben</groupId>
+        <artifactId>zstd-jni</artifactId>
+        <version>${zstd.version}</version>
+      </dependency>
+
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-plugins</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.jimfs</groupId>
+      <artifactId>jimfs</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>default-test</id>
+            <configuration>
+              <excludes>
+                <exclude>org/apache/logging/log4j/compress/commons/lzma/*</exclude>
+                <exclude>org/apache/logging/log4j/compress/commons/xz/*</exclude>
+                <exclude>org/apache/logging/log4j/compress/commons/zstd/*</exclude>
+              </excludes>
+            </configuration>
+          </execution>
+          <!--
+            ~ The XZ algorithm requires additional Commons Compress dependencies
+            -->
+          <execution>
+            <id>test-xz</id>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+              <additionalClasspathDependencies>
+                <dependency>
+                  <groupId>org.tukaani</groupId>
+                  <artifactId>xz</artifactId>
+                  <version>${xz.version}</version>
+                </dependency>
+              </additionalClasspathDependencies>
+              <includes>
+                <include>org/apache/logging/log4j/compress/commons/xz/*Test.class</include>

Review Comment:
   There is no `lzma` package.
   
   I removed the misleading `lzma` exclusion in https://github.com/apache/logging-log4j2/pull/2921/commits/6627024993f48f1289184ec3ef04729068955b0b



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757408818


##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>
+  <name>Apache Log4j Core: Extended Compression Support</name>
+  <description>Add additional compression formats to Log4j Core.</description>
+
+  <properties>
+    <commons-compress.version>1.27.1</commons-compress.version>
+    <jimfs.version>1.3.0</jimfs.version>
+    <xz.version>1.10</xz.version>
+    <zstd.version>1.5.6-5</zstd.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>${commons-compress.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.google.jimfs</groupId>
+        <artifactId>jimfs</artifactId>
+        <version>${jimfs.version}</version>
+      </dependency>

Review Comment:
   Fixed in https://github.com/apache/logging-log4j2/pull/2921/commits/8c8c55bb264e2459465bb9674c9ec1d856bc5503



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757393575


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompressActionFactory.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.logging.log4j.core.util.FileUtils;
+import org.apache.logging.log4j.core.util.NetUtils;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A factory to produce actions that compress log files.
+ */
+@NullMarked
+public interface CompressActionFactory {
+
+    /**
+     * Option to specify the compression level.
+     * <p>
+     *     The value must be an {@code int} between -1 (default) and 9.
+     * </p>
+     */
+    String COMPRESSION_LEVEL = "compressionLevel";

Review Comment:
   Ad. 1
   This option is hardcoded in the configuration of each `RolloverStrategy`, which currently provides a compression level as only way to configure configuration. This seems as a good intersection point between `RolloverStrategy` (which uses `CompressActionFactory`) and two `CompressActionFactory` implementations, which actually use the parameter. What better place would you suggest?
   
   Ad. 2
   Would you prefer `Map<String, String>`? There are multiple approaches to provide a generic way to pass parameters for an _a priori_ unknown `CompressActionFactory`:
   
   - a `Map<String, String>`, which does not generate any `ClassCastException`s, but might generate parsing errors if a parameter can not be parsed (e.g. the value of `compressionLevel` can not be parsed as string).
   - a `Map<String, ?>, which does not suffer from parsing errors, but causes `ClassCastException`s. :cry: 
   - a marker interface, so that each algorithm can provide its own well-typed object/record. This will cause `IllegalArgumentException`s if the params for factory A are passed to factory B.
   - parameterize `CompressActionFactory` with the type of options it uses. Everything works nicely in the code, but we are mostly using reflection.
   
   I don't have a preferred strategy, but the `Map` approaches have the advantage that we can provide the user with a way to fill in a `Map`, pass it to Commons Compress and let it worry about interpreting them.
   With this approach, if Commons Compress adds additional options to [GzipParameters](https://javadoc.io/doc/org.apache.commons/commons-compress/latest/org/apache/commons/compress/compressors/gzip/GzipParameters.html), users could immediately profit from them (assuming we add code to convert `Map` to `GzipParameters`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757409312


##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>
+  <name>Apache Log4j Core: Extended Compression Support</name>
+  <description>Add additional compression formats to Log4j Core.</description>
+
+  <properties>
+    <commons-compress.version>1.27.1</commons-compress.version>
+    <jimfs.version>1.3.0</jimfs.version>
+    <xz.version>1.10</xz.version>
+    <zstd.version>1.5.6-5</zstd.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>${commons-compress.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.google.jimfs</groupId>
+        <artifactId>jimfs</artifactId>
+        <version>${jimfs.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.tukaani</groupId>
+        <artifactId>xz</artifactId>
+        <version>${xz.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.github.luben</groupId>
+        <artifactId>zstd-jni</artifactId>
+        <version>${zstd.version}</version>
+      </dependency>

Review Comment:
   Dependabot must be able to upgrade these dependencies. I added comments in https://github.com/apache/logging-log4j2/pull/2921/commits/8c8c55bb264e2459465bb9674c9ec1d856bc5503.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#issuecomment-2372385654

   
   
   <table>
       <tr>
           <th>Job</th>
           <th>Requested goals</th>
           <th>Build Tool Version</th>
           <th>Build Outcome</th>
           <th>Build ScanĀ®</th>
       </tr>
       <tr>
           <td>build-ubuntu-latest</td>
           <td>clean install</td>
           <td align='center'>3.9.8</td>
           <td align='center'>:white_check_mark:</td>
           <td><a href="https://scans.gradle.com" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-NOT_PUBLISHED-lightgrey?logo=Gradle" alt="Build Scan NOT_PUBLISHED" /></a></td>
       </tr>
   </table>
       
   
   ###### Generated by gradle/develocity-actions
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757353608


##########
log4j-core/pom.xml:
##########
@@ -44,7 +44,6 @@
       <!-- Annotations only -->
       org.jspecify.*;resolution:=optional,
       <!-- External optional dependencies -->
-      org.apache.commons.compress.*;resolution:=optional,

Review Comment:
   1. Maybe, if it appears as `transitive`, I'll fix it when merging #2930
   2. BND adds `transitive` only if a dependency type appears in the signature of a public method or extends/implements clauses of a public class/interface. This is not the case of Commons Compress.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1757426801


##########
src/site/antora/modules/ROOT/partials/features/compression.adoc:
##########


Review Comment:
   I wouldn't bother making 2.x compression algorithms extensible.
   
   However I have already aligned the 2.x documentation to use a `features/compression.adoc` file in 8069c73c971f67dabcf01a6564ba0f91511be0f5.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1758672975


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompressActionFactory.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.logging.log4j.core.util.FileUtils;
+import org.apache.logging.log4j.core.util.NetUtils;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A factory to produce actions that compress log files.
+ */
+@NullMarked
+public interface CompressActionFactory {
+
+    /**
+     * Option to specify the compression level.
+     * <p>
+     *     The value must be an {@code int} between -1 (default) and 9.
+     * </p>
+     */
+    String COMPRESSION_LEVEL = "compressionLevel";

Review Comment:
   I see. Given compression is activated based on the extension of the archived file name, can we instead
   
   1. Remove/Deprecate the hardcoded `compressionLevel` attribute, and
   2. Create a new `Compression` element holding arbitrary key-value pairs?
   
   Example snippet:
   
   ```xml
   <RollingFile name="FILE"
                fileName="/var/log/app.log"
                filePattern="/var/log/app.log.%i.gz"> 
     <JsonTemplateLayout/>
     <DefaultRolloverStrategy max="15"/> 
     <Policies>
       <CronTriggeringPolicy schedule="0 0 0 * * ?"/> 
       <SizeBasedTriggeringPolicy size="100k"/> 
     </Policies>
     <Compression>
       <level>10</level>
       <algorithm>gzip</algorithm>
       <bufferSize>8192</bufferSize>
     </Compression>
   </RollingFile>
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1756378619


##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>
+  <name>Apache Log4j Core: Extended Compression Support</name>
+  <description>Add additional compression formats to Log4j Core.</description>
+
+  <properties>
+    <commons-compress.version>1.27.1</commons-compress.version>
+    <jimfs.version>1.3.0</jimfs.version>
+    <xz.version>1.10</xz.version>
+    <zstd.version>1.5.6-5</zstd.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>${commons-compress.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.google.jimfs</groupId>
+        <artifactId>jimfs</artifactId>
+        <version>${jimfs.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.tukaani</groupId>
+        <artifactId>xz</artifactId>
+        <version>${xz.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.github.luben</groupId>
+        <artifactId>zstd-jni</artifactId>
+        <version>${zstd.version}</version>
+      </dependency>

Review Comment:
   These dependencies are only used in certain `maven-surefire-plugin` executions, and once. Why do we need to duplicate them in the `dependencyManagement`?



##########
log4j-compress/src/main/java/org/apache/logging/log4j/compress/commons/CommonsCompressAction.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.compress.commons;
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.util.Objects;
+import org.apache.commons.compress.compressors.CompressorException;
+import org.apache.commons.compress.compressors.CompressorStreamProvider;
+import org.apache.logging.log4j.core.appender.rolling.action.AbstractCompressAction;
+
+/**
+ * Compresses a file using bzip2 compression.
+ */
+final class CommonsCompressAction extends AbstractCompressAction {
+
+    private final CompressorStreamProvider provider;
+
+    /**
+     * Compressor name. One of "gz", "bzip2", "xz", "pack200" or "deflate".
+     */
+    private final String name;
+
+    /**
+     * Creates new instance of Bzip2CompressAction.
+     *
+     * @param name The compressor name. One of "gz", "bzip2", "xz", "pack200", or "deflate".
+     * @param source The file to compress, may not be null.
+     * @param destination The compressed file, may not be null.
+     */
+    CommonsCompressAction(
+            final CompressorStreamProvider provider, final String name, final Path source, final Path destination) {
+        super(source, destination);
+        this.provider = Objects.requireNonNull(provider);
+        this.name = Objects.requireNonNull(name, "name");
+    }
+
+    @Override
+    protected OutputStream wrapOutputStream(OutputStream stream) throws IOException {
+        try {
+            return new BufferedOutputStream(provider.createCompressorOutputStream(name, stream), BUF_SIZE);
+        } catch (final CompressorException e) {
+            throw new IOException(e);

Review Comment:
   ```suggestion
           } catch (final CompressorException error) {
               final String message = String.format("failed to wrap the output stream with the `%s` compressor", name);
               throw new IOException(message, error);
   ```



##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>

Review Comment:
   *Thinking out loudly:* Shouldn't we rather rename this to `log4j-compress-commons`, in case we want to support another 3rd party library in the future? :thinking:



##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>
+  <name>Apache Log4j Core: Extended Compression Support</name>
+  <description>Add additional compression formats to Log4j Core.</description>
+
+  <properties>
+    <commons-compress.version>1.27.1</commons-compress.version>
+    <jimfs.version>1.3.0</jimfs.version>
+    <xz.version>1.10</xz.version>
+    <zstd.version>1.5.6-5</zstd.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>${commons-compress.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.google.jimfs</groupId>
+        <artifactId>jimfs</artifactId>
+        <version>${jimfs.version}</version>
+      </dependency>

Review Comment:
   These dependencies are only used by this very module, and once. Why do we need to duplicate them in the `dependencyManagement`?



##########
src/site/antora/modules/ROOT/pages/manual/appenders/rolling-file.adoc:
##########
@@ -926,80 +926,56 @@ When the current log file is archived, the rolling file appender can compress it
 Compression is activated, based on the extension of the archived file name.
 The following extensions are recognized:
 
-[cols="1,1,2"]
-|===
-| Extension | Supports `compressionLevel` | Description
-
-
-| [[RolloverStrategy-compress-zip]]`.zip`
-| {check-mark}
-| ZIP archive using the
+`.zip`::
+ZIP archive using the
 https://docs.oracle.com/javase/8/docs/api/java/util/zip/DeflaterOutputStream.html[DEFLATE]
-algorithm
-
-| [[RolloverStrategy-compress-gz]]`.gz`
-| {check-mark}
-| https://docs.oracle.com/javase/8/docs/api/java/util/zip/GZIPOutputStream.html[GZIP] archive using the DEFLATE algorithm
-
-| [[RolloverStrategy-compress-bz2]]`.bz2`<<commons-compress-dep,^dep^>>
-| {x-mark}
-|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.html[BZip2] algorithm
+algorithm.
++
+The compression level can be specified using <<RolloverStrategy-attr-compressionLevel,`compressionLevel`>> configuration attribute.
 
-| [[RolloverStrategy-compress-deflate]]`.deflate`<<commons-compress-dep,^dep^>>
-| {x-mark}
-| https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/compressors/deflate/DeflateCompressorOutputStream.html[DEFLATE] algorithm
+`.gz`::
+https://docs.oracle.com/javase/8/docs/api/java/util/zip/GZIPOutputStream.html[GZIP]
+archive using the DEFLATE algorithm.
++
+The compression level can be specified using <<RolloverStrategy-attr-compressionLevel,`compressionLevel`>> configuration attribute.
 
-| [[RolloverStrategy-compress-pack200]]`.pack200`<<commons-compress-dep,^dep^>>
-| {x-mark}
-| https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/compressors/pack200/package-summary.html[Pack200] algorithm
+[#RolloverStrategy-compress-commons]
+`.<algorithmName>`::
++
+Log4j Core supports all the compression algorithms available through
+https://commons.apache.org/proper/commons-compress/index.html[Apache Commons Compress].
+To use these algorithms, an additional dependency is required:
++
+--
+include::partial$features/compression.adoc[]
+--
++
+[NOTE]
+====
+Apache Commons Compress currently supports the following values of `algorithmName`:
 
-| [[RolloverStrategy-compress-xz]]`.xz` <<commons-compress-dep,^dep^>>
-| {x-mark}
-| https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/compressors/xz/package-summary.html[XZ] algorithm
+* `gzip`, `bzip2`, `deflate`, `snappy-framed`, `lz4-block`, `lz4-framed` are supported without **any** external dependency.
+* `lzma`, `.xz` and `.zst` extensions require **additional** Commons Compress dependencies.

Review Comment:
   ```suggestion
   * `lzma`, `.xz` and `.zst` extensions require **additional** dependencies.
   ```



##########
src/site/antora/modules/ROOT/pages/components.adoc:
##########
@@ -53,6 +53,23 @@ See xref:manual/async.adoc[asynchronous loggers] for more details.
 
 include::partial$components/log4j-async-logger.adoc[]
 
+[#log4j-compress]
+== `log4j-compress`
+
+[cols="1h,5"]
+|===
+| JPMS module
+| `org.apache.logging.log4j.compress`
+|===
+
+The `log4j-compress` artifact provides additional compression algorithms to the
+xref:manual/appenders/rolling-file.adoc[].
+
+See
+xref:manual/appenders/rolling-file.adoc#RolloverStrategy-compress-commons[Compressing archived files] for more details.

Review Comment:
   Let's (try to?) emphasize that `log4j-compress` is not only for rolling file appenders.
   ```suggestion
   The `log4j-compress` artifact provides additional compression algorithms.
   Having this artifact in the classpath makes these automatically accessible to
   xref:manual/appenders/rolling-file.adoc[].
   See
   xref:manual/appenders/rolling-file.adoc#RolloverStrategy-compress-commons[Compressing archived files] for more details.
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractCompressAction.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Objects;
+
+public abstract class AbstractCompressAction extends AbstractAction {
+
+    protected static final int BUF_SIZE = 8192;
+
+    /**
+     * Source file.
+     */
+    private final Path source;
+
+    /**
+     * Destination file.
+     */
+    private final Path destination;
+
+    public AbstractCompressAction(final Path source, final Path destination) {
+        this.source = Objects.requireNonNull(source, "source");
+        this.destination = Objects.requireNonNull(destination, "destination");
+    }
+
+    /**
+     * The name of this compression algorithm.
+     * <p>
+     *     When applicable, it should correspond to the name used by Apache Commons Compress.
+     * </p>
+     */
+    protected abstract String getAlgorithmName();
+
+    /**
+     * Wraps an output stream into a compressing output stream.
+     *
+     * @param stream The stream to wrap.
+     * @return A compressing output stream.
+     */
+    protected abstract OutputStream wrapOutputStream(final OutputStream stream) throws IOException;
+
+    @Override
+    public boolean execute() throws IOException {
+        if (Files.exists(source)) {
+            LOGGER.debug("Starting {} compression from {} to {}.", getAlgorithmName(), source, destination);
+            try (final OutputStream output = wrapOutputStream(Files.newOutputStream(destination))) {
+                Files.copy(source, output);
+            }
+            LOGGER.debug("Finished {} compression from {} to {}.", getAlgorithmName(), source, destination);
+            try {
+                Files.delete(source);
+                LOGGER.debug("File {} deleted successfully.", source);
+            } catch (final IOException ioe) {
+                LOGGER.warn("Unable to delete {}.", source);

Review Comment:
   ```suggestion
                   LOGGER.warn("Unable to delete {}.", source, ioe);
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompressActionFactory.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.logging.log4j.core.util.FileUtils;
+import org.apache.logging.log4j.core.util.NetUtils;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A factory to produce actions that compress log files.
+ */
+@NullMarked
+public interface CompressActionFactory {
+
+    /**
+     * Option to specify the compression level.
+     * <p>
+     *     The value must be an {@code int} between -1 (default) and 9.
+     * </p>
+     */
+    String COMPRESSION_LEVEL = "compressionLevel";

Review Comment:
   IMHO,
   
   1. This is not the correct place for this configuration option name.
   2. We shouldn't pass configurations in a `Map<String, ?>`, but in a well-typed object/record instead. Can't we adapt the code in that direction instead?



##########
src/site/antora/modules/ROOT/partials/features/compression.adoc:
##########


Review Comment:
   Are we gonna port this to `2.x`? If not, I guess we should remove this one.



##########
log4j-core/pom.xml:
##########
@@ -44,7 +44,6 @@
       <!-- Annotations only -->
       org.jspecify.*;resolution:=optional,
       <!-- External optional dependencies -->
-      org.apache.commons.compress.*;resolution:=optional,

Review Comment:
   1. Shouldn't we have `org.jspecify;transitive=false` in `bnd-extra-module-options`?
   2. Why didn't we have `org.apache.commons.compress.*;transitive=false` in `bnd-extra-module-options`?



##########
log4j-compress/pom.xml:
##########
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-compress</artifactId>
+  <name>Apache Log4j Core: Extended Compression Support</name>
+  <description>Add additional compression formats to Log4j Core.</description>
+
+  <properties>
+    <commons-compress.version>1.27.1</commons-compress.version>
+    <jimfs.version>1.3.0</jimfs.version>
+    <xz.version>1.10</xz.version>
+    <zstd.version>1.5.6-5</zstd.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>${commons-compress.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.google.jimfs</groupId>
+        <artifactId>jimfs</artifactId>
+        <version>${jimfs.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.tukaani</groupId>
+        <artifactId>xz</artifactId>
+        <version>${xz.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.github.luben</groupId>
+        <artifactId>zstd-jni</artifactId>
+        <version>${zstd.version}</version>
+      </dependency>
+
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-plugins</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.jimfs</groupId>
+      <artifactId>jimfs</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>default-test</id>
+            <configuration>
+              <excludes>
+                <exclude>org/apache/logging/log4j/compress/commons/lzma/*</exclude>
+                <exclude>org/apache/logging/log4j/compress/commons/xz/*</exclude>
+                <exclude>org/apache/logging/log4j/compress/commons/zstd/*</exclude>
+              </excludes>
+            </configuration>
+          </execution>
+          <!--
+            ~ The XZ algorithm requires additional Commons Compress dependencies
+            -->
+          <execution>
+            <id>test-xz</id>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+              <additionalClasspathDependencies>
+                <dependency>
+                  <groupId>org.tukaani</groupId>
+                  <artifactId>xz</artifactId>
+                  <version>${xz.version}</version>
+                </dependency>
+              </additionalClasspathDependencies>
+              <includes>
+                <include>org/apache/logging/log4j/compress/commons/xz/*Test.class</include>

Review Comment:
   Shouldn't we have LZMA here also?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move compression into new `log4j-compress` module (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2921:
URL: https://github.com/apache/logging-log4j2/pull/2921#discussion_r1759029794


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompressActionFactory.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.logging.log4j.core.util.FileUtils;
+import org.apache.logging.log4j.core.util.NetUtils;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * A factory to produce actions that compress log files.
+ */
+@NullMarked
+public interface CompressActionFactory {
+
+    /**
+     * Option to specify the compression level.
+     * <p>
+     *     The value must be an {@code int} between -1 (default) and 9.
+     * </p>
+     */
+    String COMPRESSION_LEVEL = "compressionLevel";

Review Comment:
   I created #2950 test for user support for this idea.
   
   In the meantime I have implemented the removal of `compressionLevel` in https://github.com/apache/logging-log4j2/pull/2921/commits/806a0be16e43dff72b5f0645d704b594d30a8bbb



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org