|
| 1 | +//// |
| 2 | +Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +contributor license agreements. See the NOTICE file distributed with |
| 4 | +this work for additional information regarding copyright ownership. |
| 5 | +The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +(the "License"); you may not use this file except in compliance with |
| 7 | +the License. You may obtain a copy of the License at |
| 8 | + |
| 9 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + |
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +//// |
| 17 | + |
| 18 | += Log4j Configuration Converter API |
| 19 | + |
| 20 | +To help users migrate between |
| 21 | +{logging-services-url}/log4j/2.x/manual/installation.html#concepts[logging implementations] |
| 22 | +the Log4j Configuration Converter offers a simple API to convert configuration files from one format to another. |
| 23 | + |
| 24 | +[#api] |
| 25 | +== Using the API |
| 26 | + |
| 27 | +The API is based on a single |
| 28 | +link:javadoc/log4j-converter-config/org/apache/logging/log4j/converter/config/ConfigurationConverter.html[`ConfigurationConverter`] |
| 29 | +interface. |
| 30 | +To use it, first import the `log4j-converter-config` artifact to your project. |
| 31 | + |
| 32 | +[tabs] |
| 33 | +==== |
| 34 | +Maven:: |
| 35 | ++ |
| 36 | +[source,xml,subs="+attributes"] |
| 37 | +---- |
| 38 | +<plugin> |
| 39 | + <groupId>org.apache.logging.log4j</groupId> |
| 40 | + <artifactId>log4j-converter-config</artifactId> |
| 41 | + <version>{project-version}</version> |
| 42 | +</plugin> |
| 43 | +---- |
| 44 | +
|
| 45 | +Gradle:: |
| 46 | ++ |
| 47 | +[source,groovy,subs="+attributes"] |
| 48 | +---- |
| 49 | +implementation 'org.apache.logging.log4j:log4j-converter-config:{project-version}' |
| 50 | +---- |
| 51 | +==== |
| 52 | + |
| 53 | +You can access the main functionality of the library through the |
| 54 | +link:javadoc/log4j-converter-config/org/apache/logging/converter/config/ConfigurationConverter.html#convert(java.io.InputStream,java.lang.String,java.io.OutputStream,java.lang.String)[ConfigurationConverter.convert()] |
| 55 | +method, as shown in the example below: |
| 56 | + |
| 57 | +.Snippet from a {examples-url}/log4j-converter-config/Main.java[`Main.java`] CLI example |
| 58 | +[source,java,indent=0] |
| 59 | +---- |
| 60 | +include::example$log4j-converter-config/Main.java[tag=convert] |
| 61 | +---- |
| 62 | + |
| 63 | +[#formats] |
| 64 | +== Supported configuration formats |
| 65 | + |
| 66 | +The configuration converter is extensible by third-parties using the |
| 67 | +link:javadoc/log4j-converter-config/org/apache/logging/converter/config/spi/ConfigurationParser.html[`ConfigurationParser`] |
| 68 | +and |
| 69 | +link:javadoc/log4j-converter-config/org/apache/logging/converter/config/spi/ConfigurationWriter.html[`ConfigurationWriter`] |
| 70 | +interfaces from the |
| 71 | +link:javadoc/log4j-converter-config/org/apache/logging/converter/config/spi/package-summary.html[`o.a.l.l.converter.config.spi`] |
| 72 | +package. |
| 73 | + |
| 74 | +The library provides an out-of-the-box support for the following configuration formats |
| 75 | + |
| 76 | +.List of supported configuration formats |
| 77 | +[%header,cols="2h,1m,1,1"] |
| 78 | +|=== |
| 79 | +| Format name | Format id | Parsing support | Writing support |
| 80 | + |
| 81 | +| {logging-services-url}/log4j/2.x/manual/configuration.html#xml[Log4j Core 2 XML] |
| 82 | +| v2:xml |
| 83 | +| yes |
| 84 | +| yes |
| 85 | + |
| 86 | +| {logging-services-url}/log4j/2.x/manual/configuration.html#json[Log4j Core 2 JSON] |
| 87 | +| v2:json |
| 88 | +| yes |
| 89 | +| yes |
| 90 | + |
| 91 | +| {logging-services-url}/log4j/2.x/manual/configuration.html#yaml[Log4j Core 2 YAML] |
| 92 | +| v2:yaml |
| 93 | +| yes |
| 94 | +| yes |
| 95 | + |
| 96 | +| {logging-services-url}/log4j/2.x/manual/configuration.html#xml[Log4j Core 2 Properties] |
| 97 | +| v2:properties |
| 98 | +| yes |
| 99 | +| no |
| 100 | + |
| 101 | +| {logging-services-url}/log4j/2.x/manual/configuration.html#xml[Log4j Core 3 Properties] |
| 102 | +| v3:properties |
| 103 | +| yes |
| 104 | +| yes |
| 105 | +|=== |
0 commit comments