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

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 4a33fd3  LOG4J2-1360 - Add support for Platform Logger
4a33fd3 is described below

commit 4a33fd3066c91f73772606b5d0e845a7a741fbdb
Author: Ralph Goers <[email protected]>
AuthorDate: Sun Apr 5 20:58:06 2020 -0700

    LOG4J2-1360 - Add support for Platform Logger
---
 log4j-bom/pom.xml                                  |  14 +-
 log4j-jpl/pom.xml                                  | 288 +++++++++++++++++++++
 .../logging/log4j/jpl/Log4jSystemLogger.java       | 136 ++++++++++
 .../log4j/jpl/Log4jSystemLoggerAdapter.java        |  43 +++
 .../logging/log4j/jpl/Log4jSystemLoggerFinder.java |  33 +++
 .../services/java.lang.System$LoggerFinder         |   1 +
 log4j-jpl/src/site/markdown/index.md               |  30 +++
 log4j-jpl/src/site/site.xml                        |  52 ++++
 .../logging/log4j/jpl/Log4jSystemLoggerTest.java   | 122 +++++++++
 log4j-jpl/src/test/resources/log4j2-test.xml       |  39 +++
 pom.xml                                            |   6 +
 src/changes/changes.xml                            |   3 +
 src/site/site.xml                                  |   1 +
 13 files changed, 767 insertions(+), 1 deletion(-)

diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
index 5e5ac6c..11f4927 100644
--- a/log4j-bom/pom.xml
+++ b/log4j-bom/pom.xml
@@ -144,7 +144,13 @@
         <artifactId>log4j-jul</artifactId>
         <version>${project.version}</version>
       </dependency>
-      <!-- java.util.logging adapter -->
+      <!-- Java System Platform Loggerr -->
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-jpl</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <!-- Liquibase adapter -->
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-liquibase</artifactId>
@@ -156,6 +162,12 @@
         <artifactId>log4j-docker</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <!-- Kubernetes support -->
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-kubernetes</artifactId>
+        <version>${project.version}</version>
+      </dependency>
       <!-- Spring Cloud Config Client -->
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
diff --git a/log4j-jpl/pom.xml b/log4j-jpl/pom.xml
new file mode 100644
index 0000000..d0cfaca
--- /dev/null
+++ b/log4j-jpl/pom.xml
@@ -0,0 +1,288 @@
+<?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";>
+  <parent>
+    <artifactId>log4j</artifactId>
+    <groupId>org.apache.logging.log4j</groupId>
+    <version>3.0.0-SNAPSHOT</version>
+    <relativePath>../</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <properties>
+    <log4jParentDir>${basedir}/..</log4jParentDir>
+    <module.name>org.apache.logging.log4j.jpl</module.name>
+  </properties>
+
+  <artifactId>log4j-jpl</artifactId>
+  <name>Apache Log4j JDK Platform Logging Adapter</name>
+  <description>The Apache Log4j implementation of 
java.lang.System.LoggerFinder</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- Include the standard NOTICE and LICENSE -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-remote-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>process</goal>
+            </goals>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
+            <Export-Package>org.apache.logging.log4j.jpl</Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-toolchains-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>toolchain</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <toolchains>
+            <jdk>
+              <version>[11, )</version>
+            </jdk>
+          </toolchains>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>default-compile</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>default-testCompile</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <source>11</source>
+          <target>11</target>
+          <release>11</release>
+          <proc>none</proc>
+          <!-- disable errorprone -->
+          <compilerId>javac</compilerId>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <!-- Do not upgrade until 
https://issues.apache.org/jira/browse/SUREFIRE-720 is fixed -->
+        <version>2.13</version>
+        <configuration>
+          <excludes combine.self="override" />
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-changes-plugin</artifactId>
+        <version>${changes.plugin.version}</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>changes-report</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+        <configuration>
+          <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
+          <useJql>true</useJql>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${checkstyle.plugin.version}</version>
+        <configuration>
+          <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
+          
<suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <propertyExpansion>basedir=${basedir}</propertyExpansion>
+          
<propertyExpansion>licensedir=${log4jParentDir}/checkstyle-header.txt</propertyExpansion>
+          <excludes>**/module-info.java</excludes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>${javadoc.plugin.version}</version>
+        <configuration>
+          <bottom><![CDATA[<p align="center">Copyright &#169; 
{inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br />
+            Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather 
logo, the Apache Logging project logo,
+            and the Apache Log4j logo are trademarks of The Apache Software 
Foundation.</p>]]></bottom>
+          <!-- module link generation is completely broken in the javadoc 
plugin for a multi-module non-aggregating
+               project -->
+          <detectOfflineLinks>false</detectOfflineLinks>
+          <linksource>true</linksource>
+          <failOnError>false</failOnError>
+        </configuration>
+        <reportSets>
+          <reportSet>
+            <id>non-aggregate</id>
+            <reports>
+              <report>javadoc</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>${jxr.plugin.version}</version>
+        <reportSets>
+          <reportSet>
+            <id>non-aggregate</id>
+            <reports>
+              <report>jxr</report>
+            </reports>
+          </reportSet>
+          <reportSet>
+            <id>aggregate</id>
+            <reports>
+              <report>aggregate</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+  <profiles>
+    <profile>
+      <id>java11-module</id>
+      <activation>
+        <jdk>[11,)</jdk>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <!-- Use Maven Surefire 2.21 which brings module support -->
+            <version>${surefire.plugin.version}</version>
+            <!-- Disable forked VM as 2.21 yields 
https://issues.apache.org/jira/browse/SUREFIRE-720 -->
+            <configuration combine.self="override"/>
+            <executions>
+              <execution>
+                <id>test</id>
+                <phase>test</phase>
+                <goals>
+                  <goal>test</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+      <reporting>
+        <plugins>
+          <plugin>
+            <!-- spotbugs is not compatible with toolchain and needs same JDK 
than one use to compile -->
+            <groupId>com.github.spotbugs</groupId>
+            <artifactId>spotbugs-maven-plugin</artifactId>
+            <configuration>
+              <fork>true</fork>
+              <jvmArgs>-Duser.language=en</jvmArgs>
+              <threshold>Normal</threshold>
+              <effort>Default</effort>
+              
<excludeFilterFile>${log4jParentDir}/spotbugs-exclude-filter.xml</excludeFilterFile>
+            </configuration>
+          </plugin>
+          <plugin>
+            <!-- pmd is not compatible with toolchain and needs same JDK than 
one use to compile -->
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-pmd-plugin</artifactId>
+            <version>${pmd.plugin.version}</version>
+            <configuration>
+              <targetJdk>${maven.compiler.target}</targetJdk>
+            </configuration>
+          </plugin>
+        </plugins>
+      </reporting>
+    </profile>
+  </profiles>
+</project>
diff --git 
a/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLogger.java 
b/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLogger.java
new file mode 100644
index 0000000..925ca71
--- /dev/null
+++ 
b/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLogger.java
@@ -0,0 +1,136 @@
+/*
+ * 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.jpl;
+
+import java.lang.System.Logger;
+import java.util.MissingResourceException;
+import java.util.Objects;
+import java.util.ResourceBundle;
+import java.util.function.Supplier;
+
+import org.apache.logging.log4j.spi.ExtendedLogger;
+
+/**
+ * JPL {@link Logger logger} implementation that uses Log4j.
+ * Implement all default {@link Logger} methods to ensure proper class 
resolution
+ *
+ * @since 2.14
+ */
+public class Log4jSystemLogger implements Logger {
+
+    private final ExtendedLogger logger;
+
+    private static final String FQCN = Log4jSystemLogger.class.getName();
+
+    public Log4jSystemLogger(final ExtendedLogger logger) {
+        this.logger = logger;
+    }
+
+    @Override
+    public String getName() {
+        return logger.getName();
+    }
+
+    @Override
+    public boolean isLoggable(final Level level) {
+        return logger.isEnabled(getLevel(level));
+    }
+
+    @Override
+    public void log(Level level, String msg) {
+        log(level, (ResourceBundle) null, msg, (Object[]) null);
+    }
+
+    @Override
+    public void log(Level level, Supplier<String> msgSupplier) {
+        Objects.requireNonNull(msgSupplier);
+        if (isLoggable(Objects.requireNonNull(level))) {
+            log(level, (ResourceBundle) null, msgSupplier.get(), (Object[]) 
null);
+        }
+    }
+
+    @Override
+    public void log(Level level, Object obj) {
+        Objects.requireNonNull(obj);
+        if (isLoggable(Objects.requireNonNull(level))) {
+            log(level, (ResourceBundle) null, obj.toString(), (Object[]) null);
+        }
+    }
+
+    @Override
+    public void log(Level level, String msg, Throwable thrown) {
+        log(level, null, msg, thrown);
+    }
+
+    @Override
+    public void log(Level level, Supplier<String> msgSupplier, Throwable 
thrown) {
+        Objects.requireNonNull(msgSupplier);
+        if (isLoggable(Objects.requireNonNull(level))) {
+            log(level, null, msgSupplier.get(), thrown);
+        }
+    }
+
+    @Override
+    public void log(Level level, String format, Object... params) {
+        log(level, null, format, params);
+    }
+
+    @Override
+    public void log(final Level level, final ResourceBundle bundle, final 
String msg, final Throwable thrown) {
+        logger.logIfEnabled(FQCN, getLevel(level), null, getResource(bundle, 
msg), thrown);
+    }
+
+    @Override
+    public void log(final Level level, final ResourceBundle bundle, final 
String format, final Object... params) {
+        logger.logIfEnabled(FQCN, getLevel(level), null, getResource(bundle, 
format), params);
+    }
+
+    private static org.apache.logging.log4j.Level getLevel(final Level level) {
+        switch (level) {
+            case OFF:
+                return org.apache.logging.log4j.Level.OFF;
+            case ERROR:
+                return org.apache.logging.log4j.Level.ERROR;
+            case WARNING:
+                return org.apache.logging.log4j.Level.WARN;
+            case INFO:
+                return org.apache.logging.log4j.Level.INFO;
+            case DEBUG:
+                return org.apache.logging.log4j.Level.DEBUG;
+            case TRACE:
+                return org.apache.logging.log4j.Level.TRACE;
+            case ALL:
+                return org.apache.logging.log4j.Level.ALL;
+        }
+        return org.apache.logging.log4j.Level.ERROR;
+    }
+
+    private static String getResource(ResourceBundle bundle, String msg) {
+        if (bundle == null || msg == null) {
+            return msg;
+        }
+        try {
+            return bundle.getString(msg);
+        } catch (MissingResourceException e) {
+            // ignore
+            return msg;
+        } catch (ClassCastException ex) {
+            return bundle.getObject(msg).toString();
+        }
+    }
+}
diff --git 
a/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerAdapter.java
 
b/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerAdapter.java
new file mode 100644
index 0000000..3db9b52
--- /dev/null
+++ 
b/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerAdapter.java
@@ -0,0 +1,43 @@
+/*
+ * 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.jpl;
+
+import java.lang.System.Logger;
+import java.lang.System.LoggerFinder;
+
+import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
+import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.util.StackLocatorUtil;
+
+/**
+ * {@link Logger} registry implementation using just log4j-api.
+ *
+ * @since 2.14
+ */
+public class Log4jSystemLoggerAdapter extends AbstractLoggerAdapter<Logger> {
+
+    @Override
+    protected Logger newLogger(String name, LoggerContext context) {
+        return new Log4jSystemLogger(context.getLogger(name));
+    }
+
+    @Override
+    protected LoggerContext getContext() {
+        return getContext(StackLocatorUtil.getCallerClass(LoggerFinder.class));
+    }
+}
diff --git 
a/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerFinder.java
 
b/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerFinder.java
new file mode 100644
index 0000000..cb8670d
--- /dev/null
+++ 
b/log4j-jpl/src/main/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerFinder.java
@@ -0,0 +1,33 @@
+/*
+ * 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.jpl;
+
+import java.lang.System.Logger;
+
+/**
+ * @since 2.14
+ */
+public class Log4jSystemLoggerFinder extends System.LoggerFinder {
+
+    private final Log4jSystemLoggerAdapter loggerAdapter = new 
Log4jSystemLoggerAdapter();
+
+    @Override
+    public Logger getLogger(String name, Module module) {
+        return loggerAdapter.getLogger(name);
+    }
+}
diff --git 
a/log4j-jpl/src/main/resources/META-INF/services/java.lang.System$LoggerFinder 
b/log4j-jpl/src/main/resources/META-INF/services/java.lang.System$LoggerFinder
new file mode 100644
index 0000000..b959e7e
--- /dev/null
+++ 
b/log4j-jpl/src/main/resources/META-INF/services/java.lang.System$LoggerFinder
@@ -0,0 +1 @@
+org.apache.logging.log4j.jpl.Log4jSystemLoggerFinder
\ No newline at end of file
diff --git a/log4j-jpl/src/site/markdown/index.md 
b/log4j-jpl/src/site/markdown/index.md
new file mode 100644
index 0000000..1e5da79
--- /dev/null
+++ b/log4j-jpl/src/site/markdown/index.md
@@ -0,0 +1,30 @@
+<!-- vim: set syn=markdown : -->
+<!--
+    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.
+-->
+
+# Log4j 2 JDK Platform Logging Adapter
+
+The Log4j 2 JDK Logging Adapter allow to route all System.Logger events to 
Log4j 2 APIs.
+
+## Requirements
+
+The JDK Platform Logging Adapter is dependent on the Log4j API as well as Java 
11.
+
+## Usage
+
+Simply include the Log4j 2 JDK Platform Logging Adapter jar along with the 
Log4j2 jars to cause all System.Logger 
+logging to be handled by Log4j 2.
diff --git a/log4j-jpl/src/site/site.xml b/log4j-jpl/src/site/site.xml
new file mode 100644
index 0000000..fccc81f
--- /dev/null
+++ b/log4j-jpl/src/site/site.xml
@@ -0,0 +1,52 @@
+<!--
+ 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 name="Log4j JDK Platform Logging Adapter"
+         xmlns="http://maven.apache.org/DECORATION/1.4.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 
http://maven.apache.org/xsd/decoration-1.4.0.xsd";>
+  <body>
+    <links>
+      <item name="Apache" href="http://www.apache.org/"; />
+      <item name="Logging Services" href="http://logging.apache.org/"/>
+      <item name="Log4j" href="../index.html"/>
+    </links>
+
+    <!-- Component-specific reports -->
+    <menu ref="reports"/>
+
+       <!-- Overall Project Info -->
+    <menu name="Log4j Project Information" img="icon-info-sign">
+      <item name="Dependencies" href="../dependencies.html" />
+      <item name="Dependency Convergence" 
href="../dependency-convergence.html" />
+      <item name="Dependency Management" href="../dependency-management.html" 
/>
+      <item name="Project Team" href="../team-list.html" />
+      <item name="Mailing Lists" href="../mail-lists.html" />
+      <item name="Issue Tracking" href="../issue-tracking.html" />
+      <item name="Project License" href="../license.html" />
+      <item name="Source Repository" href="../source-repository.html" />
+      <item name="Project Summary" href="../project-summary.html" />
+    </menu>
+
+    <menu name="Log4j Project Reports" img="icon-cog">
+      <item name="Changes Report" href="../changes-report.html" />
+      <item name="JIRA Report" href="../jira-report.html" />
+      <item name="Surefire Report" href="../surefire-report.html" />
+      <item name="RAT Report" href="../rat-report.html" />
+    </menu>
+  </body>
+</project>
diff --git 
a/log4j-jpl/src/test/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerTest.java
 
b/log4j-jpl/src/test/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerTest.java
new file mode 100644
index 0000000..ccc4b3c
--- /dev/null
+++ 
b/log4j-jpl/src/test/java/org/apache/logging/log4j/jpl/Log4jSystemLoggerTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.jpl;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+import java.lang.System.Logger;
+import java.util.List;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class Log4jSystemLoggerTest {
+
+    public static final String LOGGER_NAME = "Test";
+    protected Logger logger;
+    protected ListAppender eventAppender;
+    protected ListAppender stringAppender;
+
+    @Before
+    public void setUp() throws Exception {
+        logger = System.getLogger(LOGGER_NAME);
+        assertThat(logger, instanceOf(Log4jSystemLogger.class));
+        eventAppender = ListAppender.getListAppender("TestAppender");
+        stringAppender = ListAppender.getListAppender("StringAppender");
+        assertNotNull(eventAppender);
+        assertNotNull(stringAppender);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (eventAppender != null) {
+            eventAppender.clear();
+        }
+        if (stringAppender != null) {
+            stringAppender.clear();
+        }
+    }
+
+    @Test
+    public void testGetName() throws Exception {
+        assertThat(logger.getName(), equalTo(LOGGER_NAME));
+    }
+
+    @Test
+    public void testIsLoggable() throws Exception {
+        assertThat(logger.isLoggable(Logger.Level.ERROR), equalTo(true));
+    }
+
+    @Test
+    public void testLog() throws Exception {
+        logger.log(Logger.Level.INFO, "Informative message here.");
+        final List<LogEvent> events = eventAppender.getEvents();
+        assertThat(events, hasSize(1));
+        final LogEvent event = events.get(0);
+        assertThat(event, instanceOf(Log4jLogEvent.class));
+        assertEquals(Level.INFO, event.getLevel());
+        assertEquals(LOGGER_NAME, event.getLoggerName());
+        assertEquals("Informative message here.", 
event.getMessage().getFormattedMessage());
+        assertEquals(Log4jSystemLogger.class.getName(), event.getLoggerFqcn());
+    }
+
+    @Test
+    public void testLogWithCallingClass() throws Exception {
+        final Logger log = System.getLogger("Test.CallerClass");
+        log.log(Logger.Level.INFO, "Calling from LoggerTest");
+        final List<String> messages = stringAppender.getMessages();
+        assertThat(messages, hasSize(1));
+        final String message = messages.get(0);
+        assertEquals(Log4jSystemLoggerTest.class.getName(), message);
+    }
+
+    @Test
+    public void testCurlyBraces() {
+        testMessage("{message}");
+    }
+
+    @Test
+    public void testPercent() {
+        testMessage("message%s");
+    }
+
+    @Test
+    public void testPercentAndCurlyBraces() {
+        testMessage("message{%s}");
+    }
+
+    private void testMessage(final String string) {
+        logger.log(Logger.Level.INFO, "Test info " + string);
+        final List<LogEvent> events = eventAppender.getEvents();
+        assertThat(events, hasSize(1));
+        for (final LogEvent event : events) {
+            final String message = event.getMessage().getFormattedMessage();
+            assertThat(message, equalTo("Test info " + string));
+        }
+    }
+}
diff --git a/log4j-jpl/src/test/resources/log4j2-test.xml 
b/log4j-jpl/src/test/resources/log4j2-test.xml
new file mode 100644
index 0000000..27cef64
--- /dev/null
+++ b/log4j-jpl/src/test/resources/log4j2-test.xml
@@ -0,0 +1,39 @@
+<!--
+  ~ 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.
+  -->
+
+<Configuration name="LoggerTest" status="OFF">
+  <Appenders>
+    <List name="TestAppender"/>
+    <List name="StringAppender">
+      <PatternLayout pattern="%class"/>
+    </List>
+    <Console name="Console" target="SYSTEM_ERR">
+      <PatternLayout pattern="%highlight{%p - %m%n}"/>
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="Test" level="DEBUG" additivity="false">
+      <AppenderRef ref="TestAppender"/>
+    </Logger>
+    <Logger name="Test.CallerClass" level="DEBUG" additivity="false">
+      <AppenderRef ref="StringAppender"/>
+    </Logger>
+    <Root level="ERROR">
+      <AppenderRef ref="Console"/>
+    </Root>
+  </Loggers>
+</Configuration>
diff --git a/pom.xml b/pom.xml
index c537b97..e2bcaa8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -406,6 +406,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-jpl</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-taglib</artifactId>
         <version>${project.version}</version>
       </dependency>
@@ -1400,6 +1405,7 @@
     <module>log4j-perf</module>
     <module>log4j-iostreams</module>
     <module>log4j-jul</module>
+    <module>log4j-jpl</module>
     <module>log4j-liquibase</module>
     <module>log4j-appserver</module>
     <module>log4j-osgi</module>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d52f022..9c8c184 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.13.2" date="2020-MM-DD" description="GA Release 
2.13.2">
+      <action issue="LOG4J2-1360" dev="rgoers" type="add" due-to="Kevin 
Leturc">
+        Provide a Log4j implementation of System.Logger.
+      </action>
       <action issue="LOG4J2-2790" dev="rgoers" type="fix" due-to="Marius 
Volkhart">
         Conditionally allocate PluginEntry during PluginCache loading.
       </action>
diff --git a/src/site/site.xml b/src/site/site.xml
index fdbccd3..3e4554c 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -308,6 +308,7 @@
       <item name="Log4j 1.2 API" href="log4j-1.2-api/index.html"/>
       <item name="SLF4J Binding" href="log4j-slf4j-impl/index.html"/>
       <item name="JUL Adapter" href="log4j-jul/index.html"/>
+      <item name="JDK Platform Logger" href="log4j-jpl/index.html"/>
       <item name="Log4j 2 to SLF4J Adapter" href="log4j-to-slf4j/index.html"/>
       <item name="Apache Flume Appender" href="log4j-flume-ng/index.html"/>
       <item name="Log4j Tag Library" href="log4j-taglib/index.html"/>

Reply via email to