You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/12/05 15:23:16 UTC

(logging-log4j-transform) branch feature/log4j-transform-cli created (now 05bb3d8)

This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a change to branch feature/log4j-transform-cli
in repository https://gitbox.apache.org/repos/asf/logging-log4j-transform.git


      at 05bb3d8  Adds a `log4j-transform-cli` tool

This branch includes the following new commits:

     new 05bb3d8  Adds a `log4j-transform-cli` tool

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(logging-log4j-transform) 01/01: Adds a `log4j-transform-cli` tool

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch feature/log4j-transform-cli
in repository https://gitbox.apache.org/repos/asf/logging-log4j-transform.git

commit 05bb3d8f19714cedda7d47d6a295ce28d736a8ea
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Thu Dec 5 16:00:05 2024 +0100

    Adds a `log4j-transform-cli` tool
    
    This PR adds a simple `picocli`-based tool to access the Configuration Converter API from the command line.
    Currently, two commands are available:
    
    - `configFile listFormats` lists the available configuration file formats.
    - `configFile convert` converts configuration files from one format to another (e.g., a Log4j 1 Properties file to a Log4j 2 Core XML file).
    
    Part of apache/logging-log4j2#3220
---
 antora-playbook.yaml                               |   1 +
 .../converter/config/ConfigurationConverter.java   |   9 +
 .../internal/DefaultConfigurationConverter.java    |  10 ++
 .../v1/PropertiesV1ConfigurationParser.java        |   5 +
 .../internal/v1/XmlV1ConfigurationParser.java      |   5 +
 .../internal/v2/JsonConfigurationMapper.java       |   5 +
 .../v2/PropertiesV2ConfigurationParser.java        |   5 +
 .../config/internal/v2/XmlConfigurationMapper.java |   5 +
 .../internal/v2/YamlConfigurationMapper.java       |   5 +
 .../v3/PropertiesV3ConfigurationMapper.java        |   5 +
 .../converter/config/spi/ConfigurationMapper.java  |  15 ++
 .../converter/config/spi/ConfigurationParser.java  |   5 +
 .../converter/config/spi/ConfigurationWriter.java  |   5 +
 log4j-transform-cli/.picocli-application-activator |  17 ++
 log4j-transform-cli/pom.xml                        | 131 ++++++++++++++
 log4j-transform-cli/src/antora/antora.yml          |  24 +++
 .../modules/ROOT/partials/configFile-convert.adoc  |  21 +++
 .../ROOT/partials/configFile-listFormats.adoc      |  21 +++
 .../transform/cli/ConfigurationFileCommands.java   | 198 +++++++++++++++++++++
 .../apache/logging/log4j/transform/cli/Main.java   |  26 ++-
 .../logging/log4j/transform/cli/Strings.java       |  24 +--
 .../logging/log4j/transform/cli/package-info.java  |  23 +--
 log4j-transform-parent/pom.xml                     |   3 +-
 pom.xml                                            |   7 +
 src/changelog/.0.x.x/add-transform-cli.xml         |  12 ++
 src/site/antora/modules/ROOT/pages/cli.adoc        |  21 ++-
 26 files changed, 554 insertions(+), 54 deletions(-)

diff --git a/antora-playbook.yaml b/antora-playbook.yaml
index eb34ee6..de8462a 100644
--- a/antora-playbook.yaml
+++ b/antora-playbook.yaml
@@ -25,6 +25,7 @@ content:
     - url: .
       branches: HEAD
       start_paths:
+        - log4j-transform-cli/target/generated-site/antora
         - target/generated-site/antora
       edit_url:
 
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/ConfigurationConverter.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/ConfigurationConverter.java
index 9060210..69a7637 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/ConfigurationConverter.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/ConfigurationConverter.java
@@ -18,6 +18,7 @@ package org.apache.logging.converter.config;
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Map;
 import java.util.Set;
 import org.apache.logging.converter.config.internal.DefaultConfigurationConverter;
 
@@ -55,4 +56,12 @@ public interface ConfigurationConverter {
      * Returns the list of supported output formats.
      */
     Set<String> getSupportedOutputFormats();
+
+    /**
+     * Associates each supported format symbol with a description.
+     * <p>
+     *     For self-documentation purposes.
+     * </p>
+     */
+    Map<String, String> getFormatDescriptions();
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/DefaultConfigurationConverter.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/DefaultConfigurationConverter.java
index cd90dd9..1edd43f 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/DefaultConfigurationConverter.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/DefaultConfigurationConverter.java
@@ -54,6 +54,7 @@ public final class DefaultConfigurationConverter implements ConfigurationConvert
 
     private final Map<String, ConfigurationParser> parsers = new HashMap<>();
     private final Map<String, ConfigurationWriter> writers = new HashMap<>();
+    private final Map<String, String> descriptions = new HashMap<>();
 
     private DefaultConfigurationConverter() {
         ServiceLoader.load(ConfigurationParser.class).forEach(parser -> parsers.put(parser.getInputFormat(), parser));
@@ -62,6 +63,10 @@ public final class DefaultConfigurationConverter implements ConfigurationConvert
             parsers.put(mapper.getInputFormat(), mapper);
             writers.put(mapper.getOutputFormat(), mapper);
         });
+        parsers.values()
+                .forEach(parser -> descriptions.put(parser.getInputFormat(), parser.getInputFormatDescription()));
+        writers.values()
+                .forEach(writer -> descriptions.put(writer.getOutputFormat(), writer.getOutputFormatDescription()));
     }
 
     @Override
@@ -98,4 +103,9 @@ public final class DefaultConfigurationConverter implements ConfigurationConvert
     public Set<String> getSupportedOutputFormats() {
         return Collections.unmodifiableSet(writers.keySet());
     }
+
+    @Override
+    public Map<String, String> getFormatDescriptions() {
+        return Collections.unmodifiableMap(descriptions);
+    }
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/PropertiesV1ConfigurationParser.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/PropertiesV1ConfigurationParser.java
index 1c174c9..75ee813 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/PropertiesV1ConfigurationParser.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/PropertiesV1ConfigurationParser.java
@@ -56,6 +56,11 @@ public class PropertiesV1ConfigurationParser extends AbstractV1ConfigurationPars
         return LOG4J_V1_PROPERTIES_FORMAT;
     }
 
+    @Override
+    public String getInputFormatDescription() {
+        return "Log4j 1 Properties configuration file format.";
+    }
+
     @Override
     public ConfigurationNode parse(InputStream inputStream) throws IOException {
         Properties properties = new Properties();
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/XmlV1ConfigurationParser.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/XmlV1ConfigurationParser.java
index 8425014..877a4ce 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/XmlV1ConfigurationParser.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v1/XmlV1ConfigurationParser.java
@@ -61,6 +61,11 @@ public class XmlV1ConfigurationParser extends AbstractV1ConfigurationParser {
         return LOG4J_V1_XML_FORMAT;
     }
 
+    @Override
+    public String getInputFormatDescription() {
+        return "Log4j 1 XML configuration file format.";
+    }
+
     @Override
     public ConfigurationNode parse(InputStream inputStream) throws IOException {
         DocumentBuilder documentBuilder = XmlUtils.createDocumentBuilderV1();
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
index d97e926..8eed7c0 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
@@ -34,4 +34,9 @@ public class JsonConfigurationMapper extends AbstractJacksonConfigurationMapper
     public String getFormat() {
         return LOG4J_V2_JSON_FORMAT;
     }
+
+    @Override
+    public String getFormatDescription() {
+        return "Log4j Core 2 JSON configuration format.";
+    }
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/PropertiesV2ConfigurationParser.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/PropertiesV2ConfigurationParser.java
index e1ef672..85fc653 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/PropertiesV2ConfigurationParser.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/PropertiesV2ConfigurationParser.java
@@ -70,6 +70,11 @@ public class PropertiesV2ConfigurationParser implements ConfigurationParser {
         return LOG4J_V2_PROPERTIES_FORMAT;
     }
 
+    @Override
+    public String getInputFormatDescription() {
+        return "Log4j Core 2 Properties configuration format.";
+    }
+
     @Override
     public ConfigurationNode parse(InputStream inputStream) throws IOException {
         Properties rootProperties = new Properties();
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/XmlConfigurationMapper.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/XmlConfigurationMapper.java
index 8f87c86..077c944 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/XmlConfigurationMapper.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/XmlConfigurationMapper.java
@@ -108,6 +108,11 @@ public class XmlConfigurationMapper implements ConfigurationMapper {
         return LOG4J_V2_XML_FORMAT;
     }
 
+    @Override
+    public String getFormatDescription() {
+        return "Log4j Core 2 XML configuration format.";
+    }
+
     private static XMLStreamWriter createStreamWriter(OutputStream outputStream) throws IOException {
         XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
         try {
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/YamlConfigurationMapper.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/YamlConfigurationMapper.java
index 6e2385b..bd2d6da 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/YamlConfigurationMapper.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/YamlConfigurationMapper.java
@@ -40,4 +40,9 @@ public class YamlConfigurationMapper extends AbstractJacksonConfigurationMapper
     public String getFormat() {
         return LOG4J_V2_YAML_FORMAT;
     }
+
+    @Override
+    public String getFormatDescription() {
+        return "Log4j Core 2 YAML configuration format.";
+    }
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v3/PropertiesV3ConfigurationMapper.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v3/PropertiesV3ConfigurationMapper.java
index 090baf4..c1f10c8 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v3/PropertiesV3ConfigurationMapper.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v3/PropertiesV3ConfigurationMapper.java
@@ -44,6 +44,11 @@ public class PropertiesV3ConfigurationMapper extends AbstractJacksonConfiguratio
         return LOG4J_V3_PROPERTIES_FORMAT;
     }
 
+    @Override
+    public String getFormatDescription() {
+        return "Log4j Core 3 Properties configuration format.";
+    }
+
     @Override
     public ConfigurationNode parse(InputStream inputStream) throws IOException {
         return super.parse(inputStream);
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationMapper.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationMapper.java
index a143e99..c46b8f4 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationMapper.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationMapper.java
@@ -35,13 +35,28 @@ public interface ConfigurationMapper extends ConfigurationParser, ConfigurationW
      */
     String getFormat();
 
+    /**
+     * A description of the supported format for self-documentation purposes.
+     */
+    String getFormatDescription();
+
     @Override
     default String getInputFormat() {
         return getFormat();
     }
 
+    @Override
+    default String getInputFormatDescription() {
+        return getFormatDescription();
+    }
+
     @Override
     default String getOutputFormat() {
         return getFormat();
     }
+
+    @Override
+    default String getOutputFormatDescription() {
+        return getFormatDescription();
+    }
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationParser.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationParser.java
index d0a943f..a7516e9 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationParser.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationParser.java
@@ -37,6 +37,11 @@ public interface ConfigurationParser {
      */
     String getInputFormat();
 
+    /**
+     * A description of the supported format for self-documentation purposes.
+     */
+    String getInputFormatDescription();
+
     /**
      * Parses a configuration file into a tree of configuration nodes.
      * <p>
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationWriter.java b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationWriter.java
index 9f2fa00..30a77c3 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationWriter.java
+++ b/log4j-converter-config/src/main/java/org/apache/logging/converter/config/spi/ConfigurationWriter.java
@@ -37,6 +37,11 @@ public interface ConfigurationWriter {
      */
     String getOutputFormat();
 
+    /**
+     * A description of the supported format for self-documentation purposes.
+     */
+    String getOutputFormatDescription();
+
     /**
      * Write a tree of configuration nodes to a configuration file.
      * <p>
diff --git a/log4j-transform-cli/.picocli-application-activator b/log4j-transform-cli/.picocli-application-activator
new file mode 100644
index 0000000..15cc6df
--- /dev/null
+++ b/log4j-transform-cli/.picocli-application-activator
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+This file activates the `picocli` profile
\ No newline at end of file
diff --git a/log4j-transform-cli/pom.xml b/log4j-transform-cli/pom.xml
new file mode 100644
index 0000000..cfdb179
--- /dev/null
+++ b/log4j-transform-cli/pom.xml
@@ -0,0 +1,131 @@
+<?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-transform-parent</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-transform-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-transform-cli</artifactId>
+  <name>Apache Log4j Transform CLI</name>
+  <description>The Apache Log4j Transform CLI tool provides access to other Log4j Transform modules such as conversion
+    between
+    configuration formats and plugin descriptors.</description>
+
+  <properties>
+    <!-- Remove after first release -->
+    <bnd.baseline.fail.on.missing>false</bnd.baseline.fail.on.missing>
+
+    <!-- Dependency versions -->
+    <commons-cli.version>1.9.0</commons-cli.version>
+
+    <!-- Main class -->
+    <Main-Class>org.apache.logging.log4j.transform.cli.Main</Main-Class>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>${commons-cli.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>info.picocli</groupId>
+      <artifactId>picocli</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-converter-config</artifactId>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+
+      <!--
+        ~ SITE section
+        ~
+        ~ Since currently the website is built using `./mvnw install && ./mvnw site`, we need to bind these plugins
+        ~ to the default lifecycle.
+        ~ Plugins in the site lifecycle will be executed **after** those of the project's reactor and therefore their
+        ~ result will be ignored.
+        -->
+
+      <!-- Copies the `antora.yml` file to the generated Antora directory structure -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-antora</id>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <phase>process-resources</phase>
+            <configuration>
+              <outputDirectory>target/generated-site/antora</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>src/antora</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- Generates the man pages for the commands -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <dependencies>
+          <dependency>
+            <groupId>info.picocli</groupId>
+            <artifactId>picocli-codegen</artifactId>
+            <version>${picocli.version}</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <id>generate-man-pages</id>
+            <goals>
+              <goal>java</goal>
+            </goals>
+            <phase>process-classes</phase>
+            <configuration>
+              <includePluginDependencies>true</includePluginDependencies>
+              <mainClass>picocli.codegen.docgen.manpage.ManPageGenerator</mainClass>
+              <arguments>
+                <arg>-d</arg>
+                <arg>${project.build.directory}/generated-site/antora/modules/ROOT/partials</arg>
+                <arg>org.apache.logging.log4j.transform.cli.ConfigurationFileCommands</arg>
+              </arguments>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+</project>
diff --git a/log4j-transform-cli/src/antora/antora.yml b/log4j-transform-cli/src/antora/antora.yml
new file mode 100644
index 0000000..569d0de
--- /dev/null
+++ b/log4j-transform-cli/src/antora/antora.yml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+#
+# This Antora module is only used as a container for automatically generated `partials`
+#
+
+name: cli
+title: Log4j Transform CLI Tools
+version: ~
diff --git a/log4j-transform-cli/src/antora/modules/ROOT/partials/configFile-convert.adoc b/log4j-transform-cli/src/antora/modules/ROOT/partials/configFile-convert.adoc
new file mode 100644
index 0000000..4c104b9
--- /dev/null
+++ b/log4j-transform-cli/src/antora/modules/ROOT/partials/configFile-convert.adoc
@@ -0,0 +1,21 @@
+////
+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
+
+    https://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.
+////
+
+= configFile-convert(1)
+
+This is a dummy file to help validation in an IDE.
+Its content will be generated by `picocli-codegen`.
\ No newline at end of file
diff --git a/log4j-transform-cli/src/antora/modules/ROOT/partials/configFile-listFormats.adoc b/log4j-transform-cli/src/antora/modules/ROOT/partials/configFile-listFormats.adoc
new file mode 100644
index 0000000..e61399a
--- /dev/null
+++ b/log4j-transform-cli/src/antora/modules/ROOT/partials/configFile-listFormats.adoc
@@ -0,0 +1,21 @@
+////
+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
+
+    https://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.
+////
+
+= configFile-listFormats(1)
+
+This is a dummy file to help validation in an IDE.
+Its content will be generated by `picocli-codegen`.
\ No newline at end of file
diff --git a/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/ConfigurationFileCommands.java b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/ConfigurationFileCommands.java
new file mode 100644
index 0000000..19a3982
--- /dev/null
+++ b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/ConfigurationFileCommands.java
@@ -0,0 +1,198 @@
+/*
+ * 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.transform.cli;
+
+import static java.util.Objects.requireNonNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import org.apache.logging.converter.config.ConfigurationConverter;
+import org.jspecify.annotations.Nullable;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
+@Command(
+        name = "configFile",
+        description = "Handles the transformation of logging configuration files.",
+        subcommands = {ConfigurationFileCommands.Convert.class, ConfigurationFileCommands.ListFormats.class})
+class ConfigurationFileCommands {
+
+    private static final int PADDING_SIZE = 2;
+
+    @Command(name = "listFormats", description = "Lists the supported configuration file formats.")
+    static class ListFormats implements Callable<Integer> {
+
+        private final ConfigurationConverter converter = ConfigurationConverter.getInstance();
+
+        @Override
+        public Integer call() {
+            Map<String, SupportedFormat> supportedFormatMap = new TreeMap<>();
+            converter
+                    .getSupportedInputFormats()
+                    .forEach(formatName -> supportedFormatMap.compute(formatName, SupportedFormat::enableInput));
+            converter
+                    .getSupportedOutputFormats()
+                    .forEach(formatName -> supportedFormatMap.compute(formatName, SupportedFormat::enableOutput));
+            converter
+                    .getFormatDescriptions()
+                    .forEach((formatName, description) -> supportedFormatMap.compute(
+                            formatName, (f, old) -> SupportedFormat.updateDescription(f, description, old)));
+            System.out.println("Supported formats:");
+            System.out.println();
+            formatRows(supportedFormatMap.values()).forEach(System.out::println);
+            return 0;
+        }
+
+        private static List<? extends CharSequence> formatRows(Collection<SupportedFormat> supportedFormats) {
+            List<StringBuilder> rows = new ArrayList<>(supportedFormats.size());
+            // Print first column
+            int maxLength = 0;
+            for (SupportedFormat format : supportedFormats) {
+                StringBuilder row = new StringBuilder();
+                Strings.appendPadding(row, PADDING_SIZE).append(format.formatName);
+                maxLength = Math.max(maxLength, row.length());
+                rows.add(row);
+            }
+            // Print second column
+            int i = 0;
+            for (SupportedFormat format : supportedFormats) {
+                StringBuilder row = rows.get(i++);
+                Strings.appendPadding(row, PADDING_SIZE + maxLength - row.length());
+                if (format.description != null) {
+                    row.append(format.description);
+                }
+                if (!format.input) {
+                    if (format.output) {
+                        row.append(" (write-only)");
+                    } else {
+                        rows.remove(--i);
+                    }
+                } else if (!format.output) {
+                    row.append(" (read-only)");
+                }
+            }
+            return rows;
+        }
+    }
+
+    @Command(name = "convert", description = "Converts a logging configuration file to a different format.")
+    static class Convert implements Callable<Integer> {
+
+        private final ConfigurationConverter converter = ConfigurationConverter.getInstance();
+
+        private @Nullable String inputFormat;
+        private @Nullable String outputFormat;
+        private @Nullable File inputFile;
+        private @Nullable File outputFile;
+
+        @Option(
+                names = {"-i", "--input-format"},
+                description = "The format of the input file.",
+                required = true)
+        public void setInputFormat(String inputFormat) {
+            if (!converter.getSupportedInputFormats().contains(inputFormat)) {
+                throw new IllegalArgumentException("Unsupported input format: `" + inputFormat
+                        + "`.\nRun `listFormats` for a list of supported formats.");
+            }
+            this.inputFormat = inputFormat;
+        }
+
+        @Option(
+                names = {"-o", "--output-format"},
+                description = "The format of the output file.",
+                required = true)
+        public void setOutputFormat(String outputFormat) {
+            if (!converter.getSupportedOutputFormats().contains(outputFormat)) {
+                throw new IllegalArgumentException("Unsupported output format: `" + outputFormat
+                        + "`.\nRun `listFormats` for a list of supported formats.");
+            }
+            this.outputFormat = outputFormat;
+        }
+
+        @Parameters(index = "0", description = "The input logging configuration file.")
+        public void setInputFile(File inputFile) {
+            if (!Files.exists(inputFile.toPath())) {
+                throw new IllegalArgumentException("Input file does not exist: `" + inputFile + "`.");
+            }
+            this.inputFile = inputFile;
+        }
+
+        @Parameters(index = "1", description = "The output logging configuration file.")
+        public void setOutputFile(File outputFile) {
+            if (Files.exists(outputFile.toPath())) {
+                throw new IllegalArgumentException("Output file already exists: `" + outputFile + "`.");
+            }
+            this.outputFile = outputFile;
+        }
+
+        @Override
+        public Integer call() throws IOException {
+            String inputFormat = requireNonNull(this.inputFormat);
+            Path inputPath = requireNonNull(this.inputFile).toPath();
+            String outputFormat = requireNonNull(this.outputFormat);
+            Path outputPath = requireNonNull(this.outputFile).toPath();
+            try (InputStream inputStream = Files.newInputStream(inputPath);
+                    OutputStream outputStream = Files.newOutputStream(outputPath)) {
+                converter.convert(inputStream, inputFormat, outputStream, outputFormat);
+            }
+            return 0;
+        }
+    }
+
+    private static final class SupportedFormat {
+        private final String formatName;
+        private final @Nullable String description;
+        private final boolean input;
+        private final boolean output;
+
+        private static SupportedFormat enableInput(String formatName, @Nullable SupportedFormat old) {
+            return new SupportedFormat(
+                    formatName, old != null ? old.formatName : null, true, old != null && old.output);
+        }
+
+        private static SupportedFormat enableOutput(String formatName, @Nullable SupportedFormat old) {
+            return new SupportedFormat(formatName, old != null ? old.formatName : null, old != null && old.input, true);
+        }
+
+        private static SupportedFormat updateDescription(
+                String formatName, String description, @Nullable SupportedFormat old) {
+            return new SupportedFormat(formatName, description, old != null && old.input, old != null && old.output);
+        }
+
+        private SupportedFormat(
+                final String formatName,
+                @Nullable final String description,
+                final boolean input,
+                final boolean output) {
+            this.formatName = formatName;
+            this.description = description;
+            this.input = input;
+            this.output = output;
+        }
+    }
+}
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/Main.java
similarity index 54%
copy from log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
copy to log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/Main.java
index d97e926..1ca5e03 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
+++ b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/Main.java
@@ -14,24 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.converter.config.internal.v2;
+package org.apache.logging.log4j.transform.cli;
 
-import aQute.bnd.annotation.Resolution;
-import aQute.bnd.annotation.spi.ServiceProvider;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import org.apache.logging.converter.config.spi.ConfigurationMapper;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
 
-@ServiceProvider(value = ConfigurationMapper.class, resolution = Resolution.MANDATORY)
-public class JsonConfigurationMapper extends AbstractJacksonConfigurationMapper {
+@Command(
+        name = "log4j-transform-cli",
+        description = "Provides several utilities that transform Log4j-related files.",
+        subcommands = {ConfigurationFileCommands.class})
+public final class Main {
 
-    private static final String LOG4J_V2_JSON_FORMAT = "v2:json";
-
-    public JsonConfigurationMapper() {
-        super(JsonMapper.builder().build(), true);
+    public static void main(final String[] args) {
+        System.exit(new CommandLine(Main.class).execute(args));
     }
 
-    @Override
-    public String getFormat() {
-        return LOG4J_V2_JSON_FORMAT;
-    }
+    private Main() {}
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/Strings.java
similarity index 54%
copy from log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
copy to log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/Strings.java
index d97e926..714d80e 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
+++ b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/Strings.java
@@ -14,24 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.converter.config.internal.v2;
+package org.apache.logging.log4j.transform.cli;
 
-import aQute.bnd.annotation.Resolution;
-import aQute.bnd.annotation.spi.ServiceProvider;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import org.apache.logging.converter.config.spi.ConfigurationMapper;
+final class Strings {
 
-@ServiceProvider(value = ConfigurationMapper.class, resolution = Resolution.MANDATORY)
-public class JsonConfigurationMapper extends AbstractJacksonConfigurationMapper {
-
-    private static final String LOG4J_V2_JSON_FORMAT = "v2:json";
-
-    public JsonConfigurationMapper() {
-        super(JsonMapper.builder().build(), true);
+    static StringBuilder appendPadding(StringBuilder appendable, int count) {
+        for (int i = 0; i < count; i++) {
+            appendable.append(' ');
+        }
+        return appendable;
     }
 
-    @Override
-    public String getFormat() {
-        return LOG4J_V2_JSON_FORMAT;
-    }
+    private Strings() {}
 }
diff --git a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/package-info.java
similarity index 53%
copy from log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
copy to log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/package-info.java
index d97e926..fffab2d 100644
--- a/log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/v2/JsonConfigurationMapper.java
+++ b/log4j-transform-cli/src/main/java/org/apache/logging/log4j/transform/cli/package-info.java
@@ -14,24 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.converter.config.internal.v2;
+@NullMarked
+package org.apache.logging.log4j.transform.cli;
 
-import aQute.bnd.annotation.Resolution;
-import aQute.bnd.annotation.spi.ServiceProvider;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import org.apache.logging.converter.config.spi.ConfigurationMapper;
-
-@ServiceProvider(value = ConfigurationMapper.class, resolution = Resolution.MANDATORY)
-public class JsonConfigurationMapper extends AbstractJacksonConfigurationMapper {
-
-    private static final String LOG4J_V2_JSON_FORMAT = "v2:json";
-
-    public JsonConfigurationMapper() {
-        super(JsonMapper.builder().build(), true);
-    }
-
-    @Override
-    public String getFormat() {
-        return LOG4J_V2_JSON_FORMAT;
-    }
-}
+import org.jspecify.annotations.NullMarked;
diff --git a/log4j-transform-parent/pom.xml b/log4j-transform-parent/pom.xml
index d7c69dc..f4f641c 100644
--- a/log4j-transform-parent/pom.xml
+++ b/log4j-transform-parent/pom.xml
@@ -211,7 +211,7 @@
       </build>
     </profile>
 
-    <!-- Profile for picocli-base applications -->
+    <!-- Profile for picocli-based applications -->
     <profile>
       <id>picocli</id>
       <activation>
@@ -259,6 +259,7 @@
                       </excludes>
                     </filter>
                   </filters>
+                  <minimizeJar>true</minimizeJar>
                   <shadedArtifactAttached>true</shadedArtifactAttached>
                   <shadedClassifierName>shaded</shadedClassifierName>
                   <transformers>
diff --git a/pom.xml b/pom.xml
index 400dcf7..528fc88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
     <module>log4j-codegen</module>
     <module>log4j-converter-config</module>
     <module>log4j-converter-plugin-descriptor</module>
+    <module>log4j-transform-cli</module>
     <module>log4j-transform-maven-plugin</module>
     <module>log4j-transform-maven-shade-plugin-extensions</module>
     <module>log4j-weaver</module>
@@ -149,6 +150,12 @@
         <version>${project.version}</version>
       </dependency>
 
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-transform-cli</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-transform-maven-plugin</artifactId>
diff --git a/src/changelog/.0.x.x/add-transform-cli.xml b/src/changelog/.0.x.x/add-transform-cli.xml
new file mode 100644
index 0000000..3ec4bf7
--- /dev/null
+++ b/src/changelog/.0.x.x/add-transform-cli.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns="https://logging.apache.org/xml/ns"
+       xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+       type="added">
+  <issue id="142" link="https://github.com/apache/logging-log4j-transform/pull/142"/>
+  <description format="asciidoc">
+    Adds a
+    xref:cli.adoc#log4j-transform-cli[`log4j-transform-cli` tool]
+    to access the functionalities of Log4j Transform from the command line.
+  </description>
+</entry>
diff --git a/src/site/antora/modules/ROOT/pages/cli.adoc b/src/site/antora/modules/ROOT/pages/cli.adoc
index 5ae4da8..dcf696c 100644
--- a/src/site/antora/modules/ROOT/pages/cli.adoc
+++ b/src/site/antora/modules/ROOT/pages/cli.adoc
@@ -257,5 +257,22 @@ A list of file paths to the runtime dependencies of your application, separated
 
 The command will filter and output each `reflect-config.json` in its original path under the `META-INF/native-image` subfolder of the output directory.
 
-[#log4j-converter-plugin-descriptor-example]
-=== Examples
\ No newline at end of file
+[#log4j-transform-cli]
+== `log4j-transform-cli`
+
+The `log4j-transform-cli` tool provides CLI access to some of the functionalities offered by
+xref:ROOT::index.adoc[].
+
+Currently, you can use it to:
+
+* Convert between different formats of logging configuration files.
+See <<log4j-transform-cli-configFile-convert>> for the syntax.
+
+* List the support configuration file formats.
+See <<log4j-transform-cli-configFile-listFormats>> for the syntax.
+
+[#log4j-transform-cli-configFile-convert]
+include::cli::partial$configFile-convert.adoc[leveloffset=2]
+
+[#log4j-transform-cli-configFile-listFormats]
+include::cli::partial$configFile-listFormats.adoc[leveloffset=2]