You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/08 00:39:09 UTC

[30/32] git commit: Rename package jdk to jul.

Rename package jdk to jul.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8986d92a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8986d92a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8986d92a

Branch: refs/heads/master
Commit: 8986d92a643cf3e42a8346625b5234f3fe6f82c7
Parents: d5fcea0
Author: Matt Sicker <ma...@apache.org>
Authored: Sun Sep 7 17:19:02 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sun Sep 7 17:19:02 2014 -0500

----------------------------------------------------------------------
 log4j-jul/pom.xml                               |   2 +-
 .../log4j/jdk/AbstractLoggerAdapter.java        |  44 -------
 .../org/apache/logging/log4j/jdk/ApiLogger.java | 130 -------------------
 .../logging/log4j/jdk/ApiLoggerAdapter.java     |  34 -----
 .../apache/logging/log4j/jdk/CoreLogger.java    |  78 -----------
 .../logging/log4j/jdk/CoreLoggerAdapter.java    |  35 -----
 .../org/apache/logging/log4j/jdk/Levels.java    | 111 ----------------
 .../apache/logging/log4j/jdk/LogManager.java    | 104 ---------------
 .../log4j/jul/AbstractLoggerAdapter.java        |  44 +++++++
 .../org/apache/logging/log4j/jul/ApiLogger.java | 130 +++++++++++++++++++
 .../logging/log4j/jul/ApiLoggerAdapter.java     |  34 +++++
 .../apache/logging/log4j/jul/CoreLogger.java    |  78 +++++++++++
 .../logging/log4j/jul/CoreLoggerAdapter.java    |  35 +++++
 .../org/apache/logging/log4j/jul/Levels.java    | 111 ++++++++++++++++
 .../apache/logging/log4j/jul/LogManager.java    | 104 +++++++++++++++
 log4j-jul/src/site/xdoc/index.xml               |   4 +-
 .../apache/logging/log4j/jdk/ApiLoggerTest.java | 127 ------------------
 .../logging/log4j/jdk/CoreLoggerTest.java       | 101 --------------
 .../logging/log4j/jdk/CustomJdkLevel.java       |  40 ------
 .../apache/logging/log4j/jdk/LevelsTest.java    |  49 -------
 .../apache/logging/log4j/jul/ApiLoggerTest.java | 127 ++++++++++++++++++
 .../logging/log4j/jul/CoreLoggerTest.java       | 101 ++++++++++++++
 .../logging/log4j/jul/CustomJdkLevel.java       |  40 ++++++
 .../apache/logging/log4j/jul/LevelsTest.java    |  49 +++++++
 24 files changed, 856 insertions(+), 856 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/pom.xml b/log4j-jul/pom.xml
index e8dc0f2..3c0e5eb 100644
--- a/log4j-jul/pom.xml
+++ b/log4j-jul/pom.xml
@@ -65,7 +65,7 @@
         <artifactId>maven-bundle-plugin</artifactId>
         <configuration>
           <instructions>
-            <Export-Package>org.apache.logging.log4j.jdk</Export-Package>
+            <Export-Package>org.apache.logging.log4j.jul</Export-Package>
           </instructions>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
deleted file mode 100644
index ce1390b..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * Abstract Logger registry. Due to the optionality of using log4j-core, there are two registries available at runtime
- * to create: {@link ApiLoggerAdapter} and {@link CoreLoggerAdapter}.
- *
- * @since 2.1
- */
-public abstract class AbstractLoggerAdapter extends org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
-
-    @Override
-    protected LoggerContext getContext() {
-        return PrivateManager.getContext();
-    }
-
-    private static class PrivateManager extends org.apache.logging.log4j.LogManager {
-        private static final String FQCN = java.util.logging.LogManager.class.getName();
-
-        public static LoggerContext getContext() {
-            return getContext(FQCN, false);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
deleted file mode 100644
index c3d3ff9..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.logging.Filter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-/**
- * Log4j API implementation of the JUL {@link Logger} class. <strong>Note that this implementation does
- * <em>not</em> use the {@link java.util.logging.Handler} class.</strong> Instead, logging is delegated to the
- * underlying Log4j {@link org.apache.logging.log4j.Logger} which may be implemented in one of many different ways.
- * Consult the documentation for your Log4j Provider for more details.
- * <p>Note that the methods {@link #getParent()} and {@link #setLevel(java.util.logging.Level)} are not supported by
- * this implementation. If you need support for these methods, then you'll need to use log4j-core.</p>
- * <p>Also note that {@link #setParent(java.util.logging.Logger)} is explicitly unsupported. Parent loggers are
- * determined using the syntax of the logger name; not through an arbitrary graph of loggers.</p>
- */
-public class ApiLogger extends Logger {
-
-    private static final String FQCN = java.util.logging.Logger.class.getName();
-
-    private static final String PREFIX = "log4j.jul.";
-
-    /**
-     * The {@link org.apache.logging.log4j.ThreadContext} key where the value of {@link java.util.logging.LogRecord#getThreadID()} will be stored.
-     */
-    public static final String THREAD_ID = PREFIX + "threadID";
-
-    /**
-     * The {@link org.apache.logging.log4j.ThreadContext} key where the value of {@link java.util.logging.LogRecord#getSequenceNumber()} will be stored.
-     */
-    public static final String SEQUENCE_NUMBER = PREFIX + "sequenceNumber";
-
-    /**
-     * The {@link org.apache.logging.log4j.ThreadContext} key where the name of the {@link java.util.logging.Level} will be stored. This is particularly useful
-     * for custom Level implementations as well as for obtaining the exact Level that was used rather than the
-     * equivalent Log4j {@link org.apache.logging.log4j.Level}.
-     */
-    public static final String LEVEL = PREFIX + "level";
-
-    private final ExtendedLogger logger;
-
-    ApiLogger(final ExtendedLogger logger) {
-        super(logger.getName(), null);
-        super.setLevel(Levels.toJavaLevel(logger.getLevel()));
-        this.logger = logger;
-    }
-
-    @Override
-    public void log(final LogRecord record) {
-        if (isFiltered(record)) {
-            return;
-        }
-        ThreadContext.put(THREAD_ID, Integer.toString(record.getThreadID()));
-        ThreadContext.put(SEQUENCE_NUMBER, Long.toString(record.getSequenceNumber()));
-        ThreadContext.put(LEVEL, record.getLevel().getName());
-        final org.apache.logging.log4j.Level level = Levels.toLevel(record.getLevel());
-        final Message message = logger.getMessageFactory().newMessage(record.getMessage(), record.getParameters());
-        final Throwable thrown = record.getThrown();
-        logger.logIfEnabled(FQCN, level, null, message, thrown);
-        ThreadContext.remove(THREAD_ID);
-        ThreadContext.remove(SEQUENCE_NUMBER);
-        ThreadContext.remove(LEVEL);
-    }
-
-    // support for Logger.getFilter()/Logger.setFilter()
-    boolean isFiltered(final LogRecord logRecord) {
-        final Filter filter = getFilter();
-        return filter != null && !filter.isLoggable(logRecord);
-    }
-
-    @Override
-    public boolean isLoggable(final Level level) {
-        return logger.isEnabled(Levels.toLevel(level));
-    }
-
-    @Override
-    public String getName() {
-        return logger.getName();
-    }
-
-    @Override
-    public void setLevel(final Level newLevel) throws SecurityException {
-        throw new UnsupportedOperationException("Cannot set level through log4j-api");
-    }
-
-    /**
-     * Provides access to {@link Logger#setLevel(java.util.logging.Level)}. This method should only be used by child
-     * classes.
-     *
-     * @see Logger#setLevel(java.util.logging.Level)
-     */
-    protected void doSetLevel(final Level newLevel) throws SecurityException {
-        super.setLevel(newLevel);
-    }
-
-    @Override
-    public Logger getParent() {
-        throw new UnsupportedOperationException("Cannot get parent logger through log4j-api");
-    }
-
-    /**
-     * Unsupported operation.
-     * @throws UnsupportedOperationException always
-     */
-    @Override
-    public void setParent(final Logger parent) {
-        throw new UnsupportedOperationException("Cannot set parent logger");
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
deleted file mode 100644
index ed71737..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * {@link Logger} registry implementation using just log4j-api. This is the fallback registry used when log4j-core is
- * not available.
- *
- * @since 2.1
- */
-public class ApiLoggerAdapter extends AbstractLoggerAdapter {
-    @Override
-    protected Logger newLogger(final String name, final LoggerContext context) {
-        return new ApiLogger(context.getLogger(name));
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
deleted file mode 100644
index ddf2aaa..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Log4j Core implementation of the JUL {@link Logger} class. <strong>Note that this implementation does
- * <em>not</em> use the {@link java.util.logging.Handler} class.</strong> Instead, logging is delegated to the
- * underlying Log4j {@link org.apache.logging.log4j.core.Logger} which uses
- * {@link org.apache.logging.log4j.core.Appender Appenders} instead.
- *
- * @since 2.1
- */
-public class CoreLogger extends ApiLogger {
-
-    private final org.apache.logging.log4j.core.Logger logger;
-
-    /**
-     * Constructs a Logger using a Log4j {@link org.apache.logging.log4j.core.Logger}.
-     *
-     * @param logger the underlying Logger to base this Logger on
-     */
-    CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
-        super(logger);
-        this.logger = logger;
-    }
-
-    @Override
-    public void setLevel(final Level level) throws SecurityException {
-        logger.setLevel(Levels.toLevel(level));
-        super.doSetLevel(level);
-    }
-
-    /**
-     * Marks the underlying {@link org.apache.logging.log4j.core.Logger} as additive.
-     *
-     * @param additive {@code true} if this Logger should be additive
-     * @see org.apache.logging.log4j.core.Logger#setAdditive(boolean)
-     */
-    @Override
-    public synchronized void setUseParentHandlers(final boolean additive) {
-        logger.setAdditive(additive);
-    }
-
-    /**
-     * Indicates if the underlying {@link org.apache.logging.log4j.core.Logger} is additive. <strong>Note that the
-     * Log4j version of JDK Loggers do <em>not</em> use Handlers.</strong>
-     *
-     * @return {@code true} if this Logger is additive, or {@code false} otherwise
-     * @see org.apache.logging.log4j.core.Logger#isAdditive()
-     */
-    @Override
-    public synchronized boolean getUseParentHandlers() {
-        return logger.isAdditive();
-    }
-
-    @Override
-    public Logger getParent() {
-        final org.apache.logging.log4j.core.Logger parent = logger.getParent();
-        return parent == null ? null : Logger.getLogger(parent.getName());
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
deleted file mode 100644
index 699ebbc..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * {@link Logger} registry implementation that uses log4j-core.
- *
- * @since 2.1
- */
-public class CoreLoggerAdapter extends AbstractLoggerAdapter {
-
-    @Override
-    protected Logger newLogger(final String name, final LoggerContext context) {
-        return new CoreLogger((org.apache.logging.log4j.core.Logger) context.getLogger(name));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/Levels.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/Levels.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/Levels.java
deleted file mode 100644
index 50354f7..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/Levels.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.jdk;
-
-import org.apache.logging.log4j.Level;
-
-/**
- * Utility class to convert between JDK Levels and Log4j 2 Levels.
- *
- * @since 2.1
- */
-public final class Levels {
-
-    private static final int JDK_OFF = java.util.logging.Level.OFF.intValue();          // OFF
-    private static final int JDK_SEVERE = java.util.logging.Level.SEVERE.intValue();    // ERROR
-    private static final int JDK_WARNING = java.util.logging.Level.WARNING.intValue();  // WARN
-    private static final int JDK_INFO = java.util.logging.Level.INFO.intValue();        // INFO
-    private static final int JDK_CONFIG = java.util.logging.Level.CONFIG.intValue();    // INFO
-    private static final int JDK_FINE = java.util.logging.Level.FINE.intValue();        // DEBUG
-    private static final int JDK_FINER = java.util.logging.Level.FINER.intValue();      // DEBUG
-    private static final int JDK_FINEST = java.util.logging.Level.FINEST.intValue();    // TRACE
-    private static final int JDK_ALL = java.util.logging.Level.ALL.intValue();          // ALL
-
-    /**
-     * Converts a JDK logging Level to a Log4j logging Level.
-     *
-     * @param level JDK Level to convert.
-     * @return converted Level.
-     */
-    public static Level toLevel(final java.util.logging.Level level) {
-        final int value = level.intValue();
-        if (value == JDK_OFF) { // Integer.MAX_VALUE
-            return Level.OFF;
-        }
-        if (value == JDK_ALL) { // Integer.MIN_VALUE
-            return Level.ALL;
-        }
-        if (value <= JDK_FINEST) { // up to 300
-            return Level.TRACE;
-        }
-        if (value <= JDK_FINER) { // 301 to 400
-            return Level.DEBUG;
-        }
-        if (value <= JDK_FINE) { // 401 to 500
-            return Level.DEBUG;
-        }
-        if (value <= JDK_CONFIG) { // 501 to 700
-            return Level.INFO;
-        }
-        if (value <= JDK_INFO) { // 701 to 800
-            return Level.INFO;
-        }
-        if (value <= JDK_WARNING) { // 801 to 900
-            return Level.WARN;
-        }
-        if (value <= JDK_SEVERE) { // 901 to 1000
-            return Level.ERROR;
-        }
-        // 1001+
-        return Level.FATAL;
-    }
-
-    /**
-     * Converts a Log4j logging Level to a JDK logging Level.
-     *
-     * @param level Log4j Level to convert.
-     * @return converted Level.
-     */
-    public static java.util.logging.Level toJavaLevel(final Level level) {
-        if (level == Level.OFF) {
-            return java.util.logging.Level.OFF;
-        }
-        if (level == Level.TRACE) {
-            return java.util.logging.Level.FINEST;
-        }
-        if (level == Level.DEBUG) {
-            return java.util.logging.Level.FINE;
-        }
-        if (level == Level.INFO) {
-            return java.util.logging.Level.INFO;
-        }
-        if (level == Level.WARN) {
-            return java.util.logging.Level.WARNING;
-        }
-        if (level == Level.ERROR || level == Level.FATAL) {
-            return java.util.logging.Level.SEVERE;
-        }
-        if (level == Level.ALL) {
-            return java.util.logging.Level.ALL;
-        }
-        return java.util.logging.Level.parse(level.name());
-    }
-
-    private Levels() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
deleted file mode 100644
index 2657a1c..0000000
--- a/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.apache.logging.log4j.util.PropertiesUtil;
-
-/**
- * Log4j implementation of {@link java.util.logging.LogManager}. Note that the system property
- * {@code java.util.logging.manager} must be set to {@code org.apache.logging.log4j.jdk.LogManager} in order to use
- * this adaptor. This LogManager requires the {@code log4j-api} library to be available. If {@code log4j-core} is
- * also available, then more features of {@link java.util.logging.Logger} are supported.
- *
- * <p>To override the default {@link AbstractLoggerAdapter} that is used, specify the Log4j property
- * {@code org.apache.logging.log4j.jdk.LoggerAdapter} and set it to the fully qualified class name of a custom
- * implementation. All implementations must have a default constructor.</p>
- *
- * @since 2.1
- */
-public class LogManager extends java.util.logging.LogManager {
-
-    /**
-     * Name of the Log4j property to set to override the {@link AbstractLoggerAdapter} to be used. By
-     * default, when this property is not set, an appropriate LoggerAdaptor is chosen based on the presence of
-     * {@code log4j-core}.
-     */
-    public static final String LOGGER_ADAPTOR_PROPERTY = "org.apache.logging.log4j.jdk.LoggerAdapter";
-
-    private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
-    private final AbstractLoggerAdapter loggerAdapter;
-
-    public LogManager() {
-        super();
-        AbstractLoggerAdapter adapter = null;
-        final String overrideAdaptorClassName =
-            PropertiesUtil.getProperties().getStringProperty(LOGGER_ADAPTOR_PROPERTY);
-        if (overrideAdaptorClassName != null) {
-            try {
-                LOGGER.info("Trying to use LoggerAdaptor [{}] specified by Log4j property.", overrideAdaptorClassName);
-                adapter = LoaderUtil.newCheckedInstanceOf(overrideAdaptorClassName, AbstractLoggerAdapter.class);
-            } catch (final Exception e) {
-                LOGGER.error("Specified LoggerAdapter [{}] is incompatible.", overrideAdaptorClassName, e);
-            }
-        }
-        if (adapter == null) {
-            // default adapter
-            String adapterClassName;
-            try {
-                // find out if log4j-core is available
-                LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
-                adapterClassName = "org.apache.logging.log4j.jdk.CoreLoggerAdapter";
-            } catch (final ClassNotFoundException ignored) {
-                adapterClassName = "org.apache.logging.log4j.jdk.ApiLoggerAdapter";
-            }
-            LOGGER.debug("Attempting to use {}", adapterClassName);
-            try {
-                adapter = LoaderUtil.newCheckedInstanceOf(adapterClassName, AbstractLoggerAdapter.class);
-            } catch (final Exception e) {
-                throw LOGGER.throwing(new LoggingException(e));
-            }
-        }
-        loggerAdapter = adapter;
-        LOGGER.info("Registered Log4j as the java.util.logging.LogManager.");
-    }
-
-    @Override
-    public boolean addLogger(final Logger logger) {
-        // in order to prevent non-bridged loggers from being registered, we always return false to indicate that
-        // the named logger should be obtained through getLogger(name)
-        return false;
-    }
-
-    @Override
-    public Logger getLogger(final String name) {
-        LOGGER.trace("Call to LogManager.getLogger({})", name);
-        return loggerAdapter.getLogger(name);
-    }
-
-    @Override
-    public Enumeration<String> getLoggerNames() {
-        return Collections.enumeration(loggerAdapter.getLoggersInContext(loggerAdapter.getContext()).keySet());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/AbstractLoggerAdapter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/AbstractLoggerAdapter.java
new file mode 100644
index 0000000..3d20876
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/AbstractLoggerAdapter.java
@@ -0,0 +1,44 @@
+/*
+ * 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.jul;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ * Abstract Logger registry. Due to the optionality of using log4j-core, there are two registries available at runtime
+ * to create: {@link ApiLoggerAdapter} and {@link CoreLoggerAdapter}.
+ *
+ * @since 2.1
+ */
+public abstract class AbstractLoggerAdapter extends org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
+
+    @Override
+    protected LoggerContext getContext() {
+        return PrivateManager.getContext();
+    }
+
+    private static class PrivateManager extends org.apache.logging.log4j.LogManager {
+        private static final String FQCN = java.util.logging.LogManager.class.getName();
+
+        public static LoggerContext getContext() {
+            return getContext(FQCN, false);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLogger.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLogger.java
new file mode 100644
index 0000000..b9cacab
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLogger.java
@@ -0,0 +1,130 @@
+/*
+ * 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.jul;
+
+import java.util.logging.Filter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+
+/**
+ * Log4j API implementation of the JUL {@link Logger} class. <strong>Note that this implementation does
+ * <em>not</em> use the {@link java.util.logging.Handler} class.</strong> Instead, logging is delegated to the
+ * underlying Log4j {@link org.apache.logging.log4j.Logger} which may be implemented in one of many different ways.
+ * Consult the documentation for your Log4j Provider for more details.
+ * <p>Note that the methods {@link #getParent()} and {@link #setLevel(java.util.logging.Level)} are not supported by
+ * this implementation. If you need support for these methods, then you'll need to use log4j-core.</p>
+ * <p>Also note that {@link #setParent(java.util.logging.Logger)} is explicitly unsupported. Parent loggers are
+ * determined using the syntax of the logger name; not through an arbitrary graph of loggers.</p>
+ */
+public class ApiLogger extends Logger {
+
+    private static final String FQCN = java.util.logging.Logger.class.getName();
+
+    private static final String PREFIX = "log4j.jul.";
+
+    /**
+     * The {@link org.apache.logging.log4j.ThreadContext} key where the value of {@link java.util.logging.LogRecord#getThreadID()} will be stored.
+     */
+    public static final String THREAD_ID = PREFIX + "threadID";
+
+    /**
+     * The {@link org.apache.logging.log4j.ThreadContext} key where the value of {@link java.util.logging.LogRecord#getSequenceNumber()} will be stored.
+     */
+    public static final String SEQUENCE_NUMBER = PREFIX + "sequenceNumber";
+
+    /**
+     * The {@link org.apache.logging.log4j.ThreadContext} key where the name of the {@link java.util.logging.Level} will be stored. This is particularly useful
+     * for custom Level implementations as well as for obtaining the exact Level that was used rather than the
+     * equivalent Log4j {@link org.apache.logging.log4j.Level}.
+     */
+    public static final String LEVEL = PREFIX + "level";
+
+    private final ExtendedLogger logger;
+
+    ApiLogger(final ExtendedLogger logger) {
+        super(logger.getName(), null);
+        super.setLevel(Levels.toJavaLevel(logger.getLevel()));
+        this.logger = logger;
+    }
+
+    @Override
+    public void log(final LogRecord record) {
+        if (isFiltered(record)) {
+            return;
+        }
+        ThreadContext.put(THREAD_ID, Integer.toString(record.getThreadID()));
+        ThreadContext.put(SEQUENCE_NUMBER, Long.toString(record.getSequenceNumber()));
+        ThreadContext.put(LEVEL, record.getLevel().getName());
+        final org.apache.logging.log4j.Level level = Levels.toLevel(record.getLevel());
+        final Message message = logger.getMessageFactory().newMessage(record.getMessage(), record.getParameters());
+        final Throwable thrown = record.getThrown();
+        logger.logIfEnabled(FQCN, level, null, message, thrown);
+        ThreadContext.remove(THREAD_ID);
+        ThreadContext.remove(SEQUENCE_NUMBER);
+        ThreadContext.remove(LEVEL);
+    }
+
+    // support for Logger.getFilter()/Logger.setFilter()
+    boolean isFiltered(final LogRecord logRecord) {
+        final Filter filter = getFilter();
+        return filter != null && !filter.isLoggable(logRecord);
+    }
+
+    @Override
+    public boolean isLoggable(final Level level) {
+        return logger.isEnabled(Levels.toLevel(level));
+    }
+
+    @Override
+    public String getName() {
+        return logger.getName();
+    }
+
+    @Override
+    public void setLevel(final Level newLevel) throws SecurityException {
+        throw new UnsupportedOperationException("Cannot set level through log4j-api");
+    }
+
+    /**
+     * Provides access to {@link Logger#setLevel(java.util.logging.Level)}. This method should only be used by child
+     * classes.
+     *
+     * @see Logger#setLevel(java.util.logging.Level)
+     */
+    protected void doSetLevel(final Level newLevel) throws SecurityException {
+        super.setLevel(newLevel);
+    }
+
+    @Override
+    public Logger getParent() {
+        throw new UnsupportedOperationException("Cannot get parent logger through log4j-api");
+    }
+
+    /**
+     * Unsupported operation.
+     * @throws UnsupportedOperationException always
+     */
+    @Override
+    public void setParent(final Logger parent) {
+        throw new UnsupportedOperationException("Cannot set parent logger");
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLoggerAdapter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLoggerAdapter.java
new file mode 100644
index 0000000..8078615
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/ApiLoggerAdapter.java
@@ -0,0 +1,34 @@
+/*
+ * 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.jul;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ * {@link Logger} registry implementation using just log4j-api. This is the fallback registry used when log4j-core is
+ * not available.
+ *
+ * @since 2.1
+ */
+public class ApiLoggerAdapter extends AbstractLoggerAdapter {
+    @Override
+    protected Logger newLogger(final String name, final LoggerContext context) {
+        return new ApiLogger(context.getLogger(name));
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
new file mode 100644
index 0000000..9887406
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLogger.java
@@ -0,0 +1,78 @@
+/*
+ * 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.jul;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Log4j Core implementation of the JUL {@link Logger} class. <strong>Note that this implementation does
+ * <em>not</em> use the {@link java.util.logging.Handler} class.</strong> Instead, logging is delegated to the
+ * underlying Log4j {@link org.apache.logging.log4j.core.Logger} which uses
+ * {@link org.apache.logging.log4j.core.Appender Appenders} instead.
+ *
+ * @since 2.1
+ */
+public class CoreLogger extends ApiLogger {
+
+    private final org.apache.logging.log4j.core.Logger logger;
+
+    /**
+     * Constructs a Logger using a Log4j {@link org.apache.logging.log4j.core.Logger}.
+     *
+     * @param logger the underlying Logger to base this Logger on
+     */
+    CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
+        super(logger);
+        this.logger = logger;
+    }
+
+    @Override
+    public void setLevel(final Level level) throws SecurityException {
+        logger.setLevel(Levels.toLevel(level));
+        super.doSetLevel(level);
+    }
+
+    /**
+     * Marks the underlying {@link org.apache.logging.log4j.core.Logger} as additive.
+     *
+     * @param additive {@code true} if this Logger should be additive
+     * @see org.apache.logging.log4j.core.Logger#setAdditive(boolean)
+     */
+    @Override
+    public synchronized void setUseParentHandlers(final boolean additive) {
+        logger.setAdditive(additive);
+    }
+
+    /**
+     * Indicates if the underlying {@link org.apache.logging.log4j.core.Logger} is additive. <strong>Note that the
+     * Log4j version of JDK Loggers do <em>not</em> use Handlers.</strong>
+     *
+     * @return {@code true} if this Logger is additive, or {@code false} otherwise
+     * @see org.apache.logging.log4j.core.Logger#isAdditive()
+     */
+    @Override
+    public synchronized boolean getUseParentHandlers() {
+        return logger.isAdditive();
+    }
+
+    @Override
+    public Logger getParent() {
+        final org.apache.logging.log4j.core.Logger parent = logger.getParent();
+        return parent == null ? null : Logger.getLogger(parent.getName());
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLoggerAdapter.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLoggerAdapter.java
new file mode 100644
index 0000000..9925422
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/CoreLoggerAdapter.java
@@ -0,0 +1,35 @@
+/*
+ * 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.jul;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ * {@link Logger} registry implementation that uses log4j-core.
+ *
+ * @since 2.1
+ */
+public class CoreLoggerAdapter extends AbstractLoggerAdapter {
+
+    @Override
+    protected Logger newLogger(final String name, final LoggerContext context) {
+        return new CoreLogger((org.apache.logging.log4j.core.Logger) context.getLogger(name));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/Levels.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/Levels.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/Levels.java
new file mode 100644
index 0000000..e8ca05e
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/Levels.java
@@ -0,0 +1,111 @@
+/*
+ * 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.jul;
+
+import org.apache.logging.log4j.Level;
+
+/**
+ * Utility class to convert between JDK Levels and Log4j 2 Levels.
+ *
+ * @since 2.1
+ */
+public final class Levels {
+
+    private static final int JDK_OFF = java.util.logging.Level.OFF.intValue();          // OFF
+    private static final int JDK_SEVERE = java.util.logging.Level.SEVERE.intValue();    // ERROR
+    private static final int JDK_WARNING = java.util.logging.Level.WARNING.intValue();  // WARN
+    private static final int JDK_INFO = java.util.logging.Level.INFO.intValue();        // INFO
+    private static final int JDK_CONFIG = java.util.logging.Level.CONFIG.intValue();    // INFO
+    private static final int JDK_FINE = java.util.logging.Level.FINE.intValue();        // DEBUG
+    private static final int JDK_FINER = java.util.logging.Level.FINER.intValue();      // DEBUG
+    private static final int JDK_FINEST = java.util.logging.Level.FINEST.intValue();    // TRACE
+    private static final int JDK_ALL = java.util.logging.Level.ALL.intValue();          // ALL
+
+    /**
+     * Converts a JDK logging Level to a Log4j logging Level.
+     *
+     * @param level JDK Level to convert.
+     * @return converted Level.
+     */
+    public static Level toLevel(final java.util.logging.Level level) {
+        final int value = level.intValue();
+        if (value == JDK_OFF) { // Integer.MAX_VALUE
+            return Level.OFF;
+        }
+        if (value == JDK_ALL) { // Integer.MIN_VALUE
+            return Level.ALL;
+        }
+        if (value <= JDK_FINEST) { // up to 300
+            return Level.TRACE;
+        }
+        if (value <= JDK_FINER) { // 301 to 400
+            return Level.DEBUG;
+        }
+        if (value <= JDK_FINE) { // 401 to 500
+            return Level.DEBUG;
+        }
+        if (value <= JDK_CONFIG) { // 501 to 700
+            return Level.INFO;
+        }
+        if (value <= JDK_INFO) { // 701 to 800
+            return Level.INFO;
+        }
+        if (value <= JDK_WARNING) { // 801 to 900
+            return Level.WARN;
+        }
+        if (value <= JDK_SEVERE) { // 901 to 1000
+            return Level.ERROR;
+        }
+        // 1001+
+        return Level.FATAL;
+    }
+
+    /**
+     * Converts a Log4j logging Level to a JDK logging Level.
+     *
+     * @param level Log4j Level to convert.
+     * @return converted Level.
+     */
+    public static java.util.logging.Level toJavaLevel(final Level level) {
+        if (level == Level.OFF) {
+            return java.util.logging.Level.OFF;
+        }
+        if (level == Level.TRACE) {
+            return java.util.logging.Level.FINEST;
+        }
+        if (level == Level.DEBUG) {
+            return java.util.logging.Level.FINE;
+        }
+        if (level == Level.INFO) {
+            return java.util.logging.Level.INFO;
+        }
+        if (level == Level.WARN) {
+            return java.util.logging.Level.WARNING;
+        }
+        if (level == Level.ERROR || level == Level.FATAL) {
+            return java.util.logging.Level.SEVERE;
+        }
+        if (level == Level.ALL) {
+            return java.util.logging.Level.ALL;
+        }
+        return java.util.logging.Level.parse(level.name());
+    }
+
+    private Levels() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LogManager.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LogManager.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LogManager.java
new file mode 100644
index 0000000..53a7f0f
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/LogManager.java
@@ -0,0 +1,104 @@
+/*
+ * 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.jul;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.LoggingException;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+import org.apache.logging.log4j.util.PropertiesUtil;
+
+/**
+ * Log4j implementation of {@link java.util.logging.LogManager}. Note that the system property
+ * {@code java.util.logging.manager} must be set to {@code org.apache.logging.log4j.jul.LogManager} in order to use
+ * this adaptor. This LogManager requires the {@code log4j-api} library to be available. If {@code log4j-core} is
+ * also available, then more features of {@link java.util.logging.Logger} are supported.
+ *
+ * <p>To override the default {@link AbstractLoggerAdapter} that is used, specify the Log4j property
+ * {@code org.apache.logging.log4j.jul.LoggerAdapter} and set it to the fully qualified class name of a custom
+ * implementation. All implementations must have a default constructor.</p>
+ *
+ * @since 2.1
+ */
+public class LogManager extends java.util.logging.LogManager {
+
+    /**
+     * Name of the Log4j property to set to override the {@link AbstractLoggerAdapter} to be used. By
+     * default, when this property is not set, an appropriate LoggerAdaptor is chosen based on the presence of
+     * {@code log4j-core}.
+     */
+    public static final String LOGGER_ADAPTOR_PROPERTY = "org.apache.logging.log4j.jul.LoggerAdapter";
+
+    private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
+    private final AbstractLoggerAdapter loggerAdapter;
+
+    public LogManager() {
+        super();
+        AbstractLoggerAdapter adapter = null;
+        final String overrideAdaptorClassName =
+            PropertiesUtil.getProperties().getStringProperty(LOGGER_ADAPTOR_PROPERTY);
+        if (overrideAdaptorClassName != null) {
+            try {
+                LOGGER.info("Trying to use LoggerAdaptor [{}] specified by Log4j property.", overrideAdaptorClassName);
+                adapter = LoaderUtil.newCheckedInstanceOf(overrideAdaptorClassName, AbstractLoggerAdapter.class);
+            } catch (final Exception e) {
+                LOGGER.error("Specified LoggerAdapter [{}] is incompatible.", overrideAdaptorClassName, e);
+            }
+        }
+        if (adapter == null) {
+            // default adapter
+            String adapterClassName;
+            try {
+                // find out if log4j-core is available
+                LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
+                adapterClassName = "org.apache.logging.log4j.jul.CoreLoggerAdapter";
+            } catch (final ClassNotFoundException ignored) {
+                adapterClassName = "org.apache.logging.log4j.jul.ApiLoggerAdapter";
+            }
+            LOGGER.debug("Attempting to use {}", adapterClassName);
+            try {
+                adapter = LoaderUtil.newCheckedInstanceOf(adapterClassName, AbstractLoggerAdapter.class);
+            } catch (final Exception e) {
+                throw LOGGER.throwing(new LoggingException(e));
+            }
+        }
+        loggerAdapter = adapter;
+        LOGGER.info("Registered Log4j as the java.util.logging.LogManager.");
+    }
+
+    @Override
+    public boolean addLogger(final Logger logger) {
+        // in order to prevent non-bridged loggers from being registered, we always return false to indicate that
+        // the named logger should be obtained through getLogger(name)
+        return false;
+    }
+
+    @Override
+    public Logger getLogger(final String name) {
+        LOGGER.trace("Call to LogManager.getLogger({})", name);
+        return loggerAdapter.getLogger(name);
+    }
+
+    @Override
+    public Enumeration<String> getLoggerNames() {
+        return Collections.enumeration(loggerAdapter.getLoggersInContext(loggerAdapter.getContext()).keySet());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/src/site/xdoc/index.xml b/log4j-jul/src/site/xdoc/index.xml
index 0b21372..5429092 100644
--- a/log4j-jul/src/site/xdoc/index.xml
+++ b/log4j-jul/src/site/xdoc/index.xml
@@ -40,11 +40,11 @@
     <section name="Usage">
       <p>
         To use the JDK Logging Adaptor, you must set the system property <code>java.util.logging.manager</code> to
-        <a class="javadoc" href="apidocs/org/apache/logging/log4j/jdk/LogManager.html">org.apache.logging.log4j.jdk.LogManager</a>
+        <a class="javadoc" href="apidocs/org/apache/logging/log4j/jul/LogManager.html">org.apache.logging.log4j.jul.LogManager</a>
       </p>
       <p>
         This must be done either through the command line (i.e., using the
-        <code>-Djava.util.logging.manager=org.apache.logging.log4j.jdk.LogManager</code> argument) or by using
+        <code>-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager</code> argument) or by using
         <code>System.setProperty()</code> before any calls are made to <code>LogManager</code> or <code>Logger</code>.
       </p>
     </section>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/ApiLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/ApiLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/ApiLoggerTest.java
deleted file mode 100644
index 5d6db02..0000000
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/ApiLoggerTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-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.BeforeClass;
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.*;
-
-public class ApiLoggerTest {
-
-    public static final String LOGGER_NAME = "Test";
-    private Logger logger;
-    private ListAppender eventAppender;
-    private ListAppender stringAppender;
-
-    @BeforeClass
-    public static void setUpClass() {
-        System.setProperty("java.util.logging.manager", LogManager.class.getName());
-        System.setProperty(LogManager.LOGGER_ADAPTOR_PROPERTY, ApiLoggerAdapter.class.getName());
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        logger = Logger.getLogger(LOGGER_NAME);
-        assertThat(logger.getLevel(), equalTo(java.util.logging.Level.FINE));
-        eventAppender = ListAppender.getListAppender("TestAppender");
-        stringAppender = ListAppender.getListAppender("StringAppender");
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        eventAppender.clear();
-    }
-
-    @Test
-    public void testLog() throws Exception {
-        logger.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(Logger.class.getName(), event.getLoggerFqcn());
-    }
-
-    @Test
-    public void testLogWithCallingClass() throws Exception {
-        final Logger log = Logger.getLogger("Test.CallerClass");
-        log.config("Calling from LoggerTest");
-        final List<String> messages = stringAppender.getMessages();
-        assertThat(messages, hasSize(1));
-        final String message = messages.get(0);
-        assertEquals(getClass().getName(), message);
-    }
-
-    @Test
-    public void testLogUsingCustomLevel() throws Exception {
-        logger.log(CustomJdkLevel.TEST, "Test level");
-        final List<LogEvent> events = eventAppender.getEvents();
-        assertThat(events, hasSize(1));
-        final LogEvent event = events.get(0);
-        assertThat(event.getLevel(), equalTo(Level.INFO));
-        final String levelName = event.getContextMap().get(ApiLogger.LEVEL);
-        assertThat(levelName, equalTo(CustomJdkLevel.TEST.getName()));
-    }
-
-    @Test
-    public void testIsLoggable() throws Exception {
-        assertThat(logger.isLoggable(java.util.logging.Level.SEVERE), equalTo(true));
-        assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1), equalTo(true));
-    }
-
-    @Test
-    public void testGetName() throws Exception {
-        assertThat(logger.getName(), equalTo(LOGGER_NAME));
-    }
-
-    @Test
-    public void testGlobalLoggerName() throws Exception {
-        final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
-        assertThat(root.getName(), equalTo(Logger.GLOBAL_LOGGER_NAME));
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void testGetParentFails() throws Exception {
-        logger.getParent();
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void testSetParentFails() throws Exception {
-        logger.setParent(null);
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void testSetLevelFails() throws Exception {
-        logger.setLevel(null);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
deleted file mode 100644
index 16d5831..0000000
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.apache.logging.log4j.jdk;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-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.BeforeClass;
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.*;
-
-public class CoreLoggerTest {
-
-    public static final String LOGGER_NAME = "Test";
-    private Logger logger;
-    private ListAppender eventAppender;
-    private ListAppender stringAppender;
-
-    @BeforeClass
-    public static void setUpClass() {
-        System.setProperty("java.util.logging.manager", LogManager.class.getName());
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        logger = Logger.getLogger(LOGGER_NAME);
-        assertThat(logger.getLevel(), equalTo(java.util.logging.Level.FINE));
-        eventAppender = ListAppender.getListAppender("TestAppender");
-        stringAppender = ListAppender.getListAppender("StringAppender");
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        eventAppender.clear();
-    }
-
-    @Test
-    public void testLog() throws Exception {
-        logger.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(Logger.class.getName(), event.getLoggerFqcn());
-    }
-
-    @Test
-    public void testLogWithCallingClass() throws Exception {
-        final Logger log = Logger.getLogger("Test.CallerClass");
-        log.config("Calling from LoggerTest");
-        final List<String> messages = stringAppender.getMessages();
-        assertThat(messages, hasSize(1));
-        final String message = messages.get(0);
-        assertEquals(getClass().getName(), message);
-    }
-
-    @Test
-    public void testLogUsingCustomLevel() throws Exception {
-        logger.log(CustomJdkLevel.TEST, "Test level");
-        final List<LogEvent> events = eventAppender.getEvents();
-        assertThat(events, hasSize(1));
-        final LogEvent event = events.get(0);
-        assertThat(event.getLevel(), equalTo(Level.INFO));
-        final String levelName = event.getContextMap().get(ApiLogger.LEVEL);
-        assertThat(levelName, equalTo(CustomJdkLevel.TEST.getName()));
-    }
-
-    @Test
-    public void testSetLevel() throws Exception {
-        logger.setLevel(java.util.logging.Level.SEVERE);
-        assertThat(logger.getLevel(), equalTo(java.util.logging.Level.SEVERE));
-    }
-
-    @Test
-    public void testIsLoggable() throws Exception {
-        assertThat(logger.isLoggable(java.util.logging.Level.SEVERE), equalTo(true));
-        assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1), equalTo(true));
-    }
-
-    @Test
-    public void testGetName() throws Exception {
-        assertThat(logger.getName(), equalTo(LOGGER_NAME));
-    }
-
-    @Test
-    public void testGlobalLoggerName() throws Exception {
-        final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
-        assertThat(root.getName(), equalTo(Logger.GLOBAL_LOGGER_NAME));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
deleted file mode 100644
index d125d0e..0000000
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.jdk;
-
-import java.util.logging.Level;
-
-/**
- * Custom JUL Level for unit tests.
- */
-public class CustomJdkLevel extends Level {
-
-    private static final long serialVersionUID = 4681718777617726164L;
-
-    protected CustomJdkLevel(final String name, final int value) {
-        super(name, value);
-    }
-
-    // inside CONFIG range; should map to INFO
-    public static final Level TEST = new CustomJdkLevel("TEST", 600);
-
-    // just 1 below Level.SEVERE; should map to ERROR
-    public static final Level DEFCON_2 = new CustomJdkLevel("DEFCON_2", 999);
-
-    // above Level.SEVERE; should map to FATAL
-    public static final Level DEFCON_1 = new CustomJdkLevel("DEFCON_1", 10000);
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
deleted file mode 100644
index b4a6056..0000000
--- a/log4j-jul/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.logging.log4j.jdk;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.apache.logging.log4j.Level;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import static org.junit.Assert.*;
-
-@RunWith(Parameterized.class)
-public class LevelsTest {
-
-    private final java.util.logging.Level level;
-    private final Level expectedLevel;
-
-    public LevelsTest(final java.util.logging.Level level, final Level expectedLevel) {
-        this.level = level;
-        this.expectedLevel = expectedLevel;
-    }
-
-    @Parameterized.Parameters
-    public static Collection<Object[]> data() {
-        return Arrays.asList(
-            new Object[][]{
-                {CustomJdkLevel.TEST, Level.INFO},
-                {CustomJdkLevel.DEFCON_2, Level.ERROR},
-                {CustomJdkLevel.DEFCON_1, Level.FATAL},
-                {java.util.logging.Level.OFF, Level.OFF},
-                {java.util.logging.Level.ALL, Level.ALL},
-                {java.util.logging.Level.SEVERE, Level.ERROR},
-                {java.util.logging.Level.WARNING, Level.WARN},
-                {java.util.logging.Level.INFO, Level.INFO},
-                {java.util.logging.Level.CONFIG, Level.INFO},
-                {java.util.logging.Level.FINE, Level.DEBUG},
-                {java.util.logging.Level.FINER, Level.DEBUG},
-                {java.util.logging.Level.FINEST, Level.TRACE}
-            }
-        );
-    }
-
-    @Test
-    public void testToLevel() throws Exception {
-        final Level actualLevel = Levels.toLevel(level);
-        assertEquals(expectedLevel, actualLevel);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/ApiLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/ApiLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/ApiLoggerTest.java
new file mode 100644
index 0000000..e26eb44
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/ApiLoggerTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.jul;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+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.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.*;
+
+public class ApiLoggerTest {
+
+    public static final String LOGGER_NAME = "Test";
+    private Logger logger;
+    private ListAppender eventAppender;
+    private ListAppender stringAppender;
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty("java.util.logging.manager", LogManager.class.getName());
+        System.setProperty(LogManager.LOGGER_ADAPTOR_PROPERTY, ApiLoggerAdapter.class.getName());
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        logger = Logger.getLogger(LOGGER_NAME);
+        assertThat(logger.getLevel(), equalTo(java.util.logging.Level.FINE));
+        eventAppender = ListAppender.getListAppender("TestAppender");
+        stringAppender = ListAppender.getListAppender("StringAppender");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        eventAppender.clear();
+    }
+
+    @Test
+    public void testLog() throws Exception {
+        logger.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(Logger.class.getName(), event.getLoggerFqcn());
+    }
+
+    @Test
+    public void testLogWithCallingClass() throws Exception {
+        final Logger log = Logger.getLogger("Test.CallerClass");
+        log.config("Calling from LoggerTest");
+        final List<String> messages = stringAppender.getMessages();
+        assertThat(messages, hasSize(1));
+        final String message = messages.get(0);
+        assertEquals(getClass().getName(), message);
+    }
+
+    @Test
+    public void testLogUsingCustomLevel() throws Exception {
+        logger.log(CustomJdkLevel.TEST, "Test level");
+        final List<LogEvent> events = eventAppender.getEvents();
+        assertThat(events, hasSize(1));
+        final LogEvent event = events.get(0);
+        assertThat(event.getLevel(), equalTo(Level.INFO));
+        final String levelName = event.getContextMap().get(ApiLogger.LEVEL);
+        assertThat(levelName, equalTo(CustomJdkLevel.TEST.getName()));
+    }
+
+    @Test
+    public void testIsLoggable() throws Exception {
+        assertThat(logger.isLoggable(java.util.logging.Level.SEVERE), equalTo(true));
+        assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1), equalTo(true));
+    }
+
+    @Test
+    public void testGetName() throws Exception {
+        assertThat(logger.getName(), equalTo(LOGGER_NAME));
+    }
+
+    @Test
+    public void testGlobalLoggerName() throws Exception {
+        final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
+        assertThat(root.getName(), equalTo(Logger.GLOBAL_LOGGER_NAME));
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testGetParentFails() throws Exception {
+        logger.getParent();
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testSetParentFails() throws Exception {
+        logger.setParent(null);
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testSetLevelFails() throws Exception {
+        logger.setLevel(null);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
new file mode 100644
index 0000000..a627f61
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CoreLoggerTest.java
@@ -0,0 +1,101 @@
+package org.apache.logging.log4j.jul;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+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.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.*;
+
+public class CoreLoggerTest {
+
+    public static final String LOGGER_NAME = "Test";
+    private Logger logger;
+    private ListAppender eventAppender;
+    private ListAppender stringAppender;
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty("java.util.logging.manager", LogManager.class.getName());
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        logger = Logger.getLogger(LOGGER_NAME);
+        assertThat(logger.getLevel(), equalTo(java.util.logging.Level.FINE));
+        eventAppender = ListAppender.getListAppender("TestAppender");
+        stringAppender = ListAppender.getListAppender("StringAppender");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        eventAppender.clear();
+    }
+
+    @Test
+    public void testLog() throws Exception {
+        logger.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(Logger.class.getName(), event.getLoggerFqcn());
+    }
+
+    @Test
+    public void testLogWithCallingClass() throws Exception {
+        final Logger log = Logger.getLogger("Test.CallerClass");
+        log.config("Calling from LoggerTest");
+        final List<String> messages = stringAppender.getMessages();
+        assertThat(messages, hasSize(1));
+        final String message = messages.get(0);
+        assertEquals(getClass().getName(), message);
+    }
+
+    @Test
+    public void testLogUsingCustomLevel() throws Exception {
+        logger.log(CustomJdkLevel.TEST, "Test level");
+        final List<LogEvent> events = eventAppender.getEvents();
+        assertThat(events, hasSize(1));
+        final LogEvent event = events.get(0);
+        assertThat(event.getLevel(), equalTo(Level.INFO));
+        final String levelName = event.getContextMap().get(ApiLogger.LEVEL);
+        assertThat(levelName, equalTo(CustomJdkLevel.TEST.getName()));
+    }
+
+    @Test
+    public void testSetLevel() throws Exception {
+        logger.setLevel(java.util.logging.Level.SEVERE);
+        assertThat(logger.getLevel(), equalTo(java.util.logging.Level.SEVERE));
+    }
+
+    @Test
+    public void testIsLoggable() throws Exception {
+        assertThat(logger.isLoggable(java.util.logging.Level.SEVERE), equalTo(true));
+        assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1), equalTo(true));
+    }
+
+    @Test
+    public void testGetName() throws Exception {
+        assertThat(logger.getName(), equalTo(LOGGER_NAME));
+    }
+
+    @Test
+    public void testGlobalLoggerName() throws Exception {
+        final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
+        assertThat(root.getName(), equalTo(Logger.GLOBAL_LOGGER_NAME));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CustomJdkLevel.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CustomJdkLevel.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CustomJdkLevel.java
new file mode 100644
index 0000000..64fd96d
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/CustomJdkLevel.java
@@ -0,0 +1,40 @@
+/*
+ * 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.jul;
+
+import java.util.logging.Level;
+
+/**
+ * Custom JUL Level for unit tests.
+ */
+public class CustomJdkLevel extends Level {
+
+    private static final long serialVersionUID = 4681718777617726164L;
+
+    protected CustomJdkLevel(final String name, final int value) {
+        super(name, value);
+    }
+
+    // inside CONFIG range; should map to INFO
+    public static final Level TEST = new CustomJdkLevel("TEST", 600);
+
+    // just 1 below Level.SEVERE; should map to ERROR
+    public static final Level DEFCON_2 = new CustomJdkLevel("DEFCON_2", 999);
+
+    // above Level.SEVERE; should map to FATAL
+    public static final Level DEFCON_1 = new CustomJdkLevel("DEFCON_1", 10000);
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8986d92a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelsTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelsTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelsTest.java
new file mode 100644
index 0000000..ae2e7e2
--- /dev/null
+++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/LevelsTest.java
@@ -0,0 +1,49 @@
+package org.apache.logging.log4j.jul;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.*;
+
+@RunWith(Parameterized.class)
+public class LevelsTest {
+
+    private final java.util.logging.Level level;
+    private final Level expectedLevel;
+
+    public LevelsTest(final java.util.logging.Level level, final Level expectedLevel) {
+        this.level = level;
+        this.expectedLevel = expectedLevel;
+    }
+
+    @Parameterized.Parameters
+    public static Collection<Object[]> data() {
+        return Arrays.asList(
+            new Object[][]{
+                {CustomJdkLevel.TEST, Level.INFO},
+                {CustomJdkLevel.DEFCON_2, Level.ERROR},
+                {CustomJdkLevel.DEFCON_1, Level.FATAL},
+                {java.util.logging.Level.OFF, Level.OFF},
+                {java.util.logging.Level.ALL, Level.ALL},
+                {java.util.logging.Level.SEVERE, Level.ERROR},
+                {java.util.logging.Level.WARNING, Level.WARN},
+                {java.util.logging.Level.INFO, Level.INFO},
+                {java.util.logging.Level.CONFIG, Level.INFO},
+                {java.util.logging.Level.FINE, Level.DEBUG},
+                {java.util.logging.Level.FINER, Level.DEBUG},
+                {java.util.logging.Level.FINEST, Level.TRACE}
+            }
+        );
+    }
+
+    @Test
+    public void testToLevel() throws Exception {
+        final Level actualLevel = Levels.toLevel(level);
+        assertEquals(expectedLevel, actualLevel);
+    }
+}
\ No newline at end of file