Discussion:
[2/2] git commit: Fix directory structure.
Remko Popma
2014-09-07 22:11:02 UTC
Permalink
Sorry for nagging, but should the package be called jul instead of jdk?

Sent from my iPhone
Fix directory structure.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c02b66be
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c02b66be
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c02b66be
Branch: refs/heads/LOG4J2-608
Commit: c02b66be95ade10e5535bb6f48bd2298aac48895
Parents: 228da65
Authored: Sun Sep 7 13:49:29 2014 -0500
Committed: Sun Sep 7 13:53:10 2014 -0500
----------------------------------------------------------------------
log4j-jul/log4j-jdk/pom.xml | 75 ---------
.../log4j/jdk/AbstractLoggerAdapter.java | 44 -----
.../org/apache/logging/log4j/jdk/ApiLogger.java | 100 -----------
.../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 | 80 ---------
log4j-jul/log4j-jdk/src/site/site.xml | 52 ------
log4j-jul/log4j-jdk/src/site/xdoc/index.xml | 168 -------------------
.../logging/log4j/jdk/CoreLoggerTest.java | 101 -----------
.../logging/log4j/jdk/CustomJdkLevel.java | 40 -----
.../apache/logging/log4j/jdk/LevelsTest.java | 49 ------
.../src/test/resources/log4j2-test.xml | 39 -----
log4j-jul/pom.xml | 75 +++++++++
.../log4j/jdk/AbstractLoggerAdapter.java | 44 +++++
.../org/apache/logging/log4j/jdk/ApiLogger.java | 100 +++++++++++
.../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 | 80 +++++++++
log4j-jul/src/site/site.xml | 52 ++++++
log4j-jul/src/site/xdoc/index.xml | 168 +++++++++++++++++++
.../logging/log4j/jdk/CoreLoggerTest.java | 101 +++++++++++
.../logging/log4j/jdk/CustomJdkLevel.java | 40 +++++
.../apache/logging/log4j/jdk/LevelsTest.java | 49 ++++++
log4j-jul/src/test/resources/log4j2-test.xml | 39 +++++
28 files changed, 1006 insertions(+), 1006 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/pom.xml b/log4j-jul/log4j-jdk/pom.xml
deleted file mode 100644
index e8dc0f2..0000000
--- a/log4j-jul/log4j-jdk/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?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>2.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>log4j-jul</artifactId>
- <name>Log4j JUL Adaptor</name>
- <description>Log4j implementation of java.util.logging</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>
- <optional>true</optional>
- </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>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>org.apache.logging.log4j.jdk</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
deleted file mode 100644
index 29f0aa0..0000000
--- a/log4j-jul/log4j-jdk/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
- *
- */
-public abstract class AbstractLoggerAdapter extends org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
-
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
deleted file mode 100644
index 6beffc9..0000000
--- a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
+++ /dev/null
@@ -1,100 +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;
-
-/**
- * Consult the documentation for your Log4j Provider for more details.
- * this implementation. If you need support for these methods, then you'll need to use log4j-core.</p>
- */
-public class ApiLogger extends Logger {
-
- private static final String FQCN = java.util.logging.Logger.class.getName();
-
- private static final String PREFIX = "log4j.jul.";
-
- /**
- */
- public static final String THREAD_ID = PREFIX + "threadID";
-
- /**
- */
- public static final String SEQUENCE_NUMBER = PREFIX + "sequenceNumber";
-
- /**
- * for custom Level implementations as well as for obtaining the exact Level that was used rather than the
- */
- 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;
- }
-
- 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);
- }
-
- public boolean isLoggable(final Level level) {
- return logger.isEnabled(Levels.toLevel(level));
- }
-
- public String getName() {
- return logger.getName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
deleted file mode 100644
index 6b3cd65..0000000
--- a/log4j-jul/log4j-jdk/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;
-
-/**
- * not available.
- *
- */
-public class ApiLoggerAdapter extends AbstractLoggerAdapter {
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
deleted file mode 100644
index 60ff82f..0000000
--- a/log4j-jul/log4j-jdk/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;
-
-/**
- *
- */
-public class CoreLogger extends ApiLogger {
-
- private final org.apache.logging.log4j.core.Logger logger;
-
- /**
- *
- */
- CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
- super(logger);
- this.logger = logger;
- }
-
- public void setLevel(final Level level) throws SecurityException {
- logger.setLevel(Levels.toLevel(level));
- super.setLevel(level);
- }
-
- /**
- *
- */
- public synchronized void setUseParentHandlers(final boolean additive) {
- logger.setAdditive(additive);
- }
-
- /**
- * Log4j version of JDK Loggers do <em>not</em> use Handlers.</strong>
- *
- */
- public synchronized boolean getUseParentHandlers() {
- return logger.isAdditive();
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
deleted file mode 100644
index d91eae1..0000000
--- a/log4j-jul/log4j-jdk/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;
-
-/**
- *
- */
-public class CoreLoggerAdapter extends AbstractLoggerAdapter {
-
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
deleted file mode 100644
index 50354f7..0000000
--- a/log4j-jul/log4j-jdk/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.
- *
- */
-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.
- *
- */
- 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.
- *
- */
- 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
deleted file mode 100644
index 8d2ae43..0000000
--- a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
+++ /dev/null
@@ -1,80 +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.spi.LoggerAdapter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
- *
- */
-public class LogManager extends java.util.logging.LogManager {
-
- private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
- private static final LoggerAdapter<Logger> ADAPTER;
-
- static {
- // find out if log4j-core is available
- String registryClassName;
- try {
- LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
- registryClassName = "org.apache.logging.log4j.jdk.CoreLoggerRegistry";
- } catch (final ClassNotFoundException ignored) {
- registryClassName = "org.apache.logging.log4j.jdk.ApiLoggerRegistry";
- }
- LOGGER.debug("Attempting to use {}", registryClassName);
- try {
- ADAPTER = LoaderUtil.newCheckedInstanceOf(registryClassName, AbstractLoggerAdapter.class);
- } catch (final Exception e) {
- throw LOGGER.throwing(new ExceptionInInitializerError(e));
- }
- }
-
- public LogManager() {
- super();
- LOGGER.info("Registered Log4j as the java.util.logging.LogManager.");
- }
-
- 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;
- }
-
- public Logger getLogger(final String name) {
- LOGGER.trace("Call to LogManager.getLogger({})", name);
- return ADAPTER.getLogger(name);
- }
-
- public Enumeration<String> getLoggerNames() {
- return Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/site/site.xml b/log4j-jul/log4j-jdk/src/site/site.xml
deleted file mode 100644
index f8c7307..0000000
--- a/log4j-jul/log4j-jdk/src/site/site.xml
+++ /dev/null
@@ -1,52 +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.
-
--->
-<project name="Log4j JDK Logging Adaptor"
- 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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/site/xdoc/index.xml b/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
deleted file mode 100644
index 0b21372..0000000
--- a/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<?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.
--->
-
-<!DOCTYPE document [<!ENTITY le "&#x2264;">]>
-<document xmlns="http://maven.apache.org/XDOC/2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
- <properties>
- <title>Log4j JDK Logging Adaptor</title>
- </properties>
- <body>
- <section name="JDK Logging Adaptor">
- <p>
- The JDK Logging Adaptor is a custom implementation of
- <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogManager.html">java.util.logging.LogManager</a>
- that uses <a href="../log4j-core/index.html">Log4j</a>.
- </p>
- </section>
- <section name="Requirements">
- <p>
- The JDK Logging Adaptor requires at least Java 6 and is dependent on the Log4j API and Log4j Core.
- </p>
- </section>
- <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>
- </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>System.setProperty()</code> before any calls are made to <code>LogManager</code> or <code>Logger</code>.
- </p>
- </section>
- <section name="Compatibility">
- <p>
- The use of a
- <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Filter.html">java.util.logging.Filter</a>
- is supported on a per-<a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html">Logger</a>
- basis. However, it is recommended to use the standard <a href="../manual/filters.html">Filters</a> feature in
- Log4j instead.
- </p>
- <p>
- The use of
- <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html">java.util.logging.Handler</a>
- classes is <em>NOT</em> supported. Custom Handlers should instead use an appropriate
- <a href="../manual/appenders.html">Appender</a> or code their own
- <a class="javadoc" href="../log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
- plugin.
- </p>
- <p>
- Java logging levels are translated into Log4j logging levels dynamically. The following table lists the
- conversions between a Java logging level and its equivalent Log4j level.
- </p>
- <table>
- <caption>Level conversions</caption>
- <thead>
- <tr>
- <th>Java Level</th>
- <th>Level Range</th>
- <th>Log4j Level</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#OFF">OFF</a></td>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE">Integer.MAX_VALUE</a></td>
- <td>OFF</td>
- </tr>
- <tr>
- <td class="muted">n/a</td>
- <td>1000 &lt; <var>level</var> &lt; <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE">Integer.MAX_VALUE</a></td>
- <td>FATAL</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#SEVERE">SEVERE</a></td>
- <td>900 &lt; <var>level</var> &le; 1000</td>
- <td>ERROR</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#WARNING">WARNING</a></td>
- <td>800 &lt; <var>level</var> &le; 900</td>
- <td>WARN</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#INFO">INFO</a></td>
- <td>700 &lt; <var>level</var> &le; 800</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#CONFIG">CONFIG</a></td>
- <td>500 &lt; <var>level</var> &le; 700</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINE">FINE</a></td>
- <td>400 &lt; <var>level</var> &le; 500</td>
- <td>DEBUG</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINER">FINER</a></td>
- <td>300 &lt; <var>level</var> &le; 400</td>
- <td>DEBUG</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINEST">FINEST</a></td>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a> &lt; <var>level</var> &le; 300</td>
- <td>TRACE</td>
- </tr>
- <tr>
- <td>ALL</td>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a></td>
- <td>ALL</td>
- </tr>
- </tbody>
- </table>
- <p>
- There are currently three additional pieces of information obtained from each
- <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a>
- that are stored in the <a href="../manual/thread-context.html">ThreadContext</a>.
- </p>
- <table>
- <caption>ThreadContext map keys</caption>
- <thead>
- <tr>
- <th>Key</th>
- <th><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a> Property</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>log4j.jul.threadID</td>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getThreadID%28%29">threadID</a></td>
- <td>An identifier for the thread where the message originated.</td>
- </tr>
- <tr>
- <td>log4j.jul.sequenceNumber</td>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getSequenceNumber%28%29">sequenceNumber</a></td>
- <td>A unique, increasing sequence number generated by the LogRecord constructor.</td>
- </tr>
- <tr>
- <td>log4j.jul.level</td>
- <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getLevel%28%29">level</a></td>
- <td>The logging message level name. This level is translated into an equivalent Log4j level, so the original
- logging level name is saved here.</td>
- </tr>
- </tbody>
- </table>
- </section>
- </body>
-</document>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
deleted file mode 100644
index 16d5831..0000000
--- a/log4j-jul/log4j-jdk/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;
-
- public static void setUpClass() {
- System.setProperty("java.util.logging.manager", LogManager.class.getName());
- }
-
- 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");
- }
-
- public void tearDown() throws Exception {
- eventAppender.clear();
- }
-
- 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());
- }
-
- 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);
- }
-
- 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()));
- }
-
- public void testSetLevel() throws Exception {
- logger.setLevel(java.util.logging.Level.SEVERE);
- assertThat(logger.getLevel(), equalTo(java.util.logging.Level.SEVERE));
- }
-
- public void testIsLoggable() throws Exception {
- assertThat(logger.isLoggable(java.util.logging.Level.SEVERE), equalTo(true));
- assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1), equalTo(true));
- }
-
- public void testGetName() throws Exception {
- assertThat(logger.getName(), equalTo(LOGGER_NAME));
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
deleted file mode 100644
index d125d0e..0000000
--- a/log4j-jul/log4j-jdk/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/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
deleted file mode 100644
index b4a6056..0000000
--- a/log4j-jul/log4j-jdk/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.*;
-
-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;
- }
-
- 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}
- }
- );
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml b/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
deleted file mode 100644
index af6a050..0000000
--- a/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,39 +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.
- -->
-
-<Configuration name="LoggerTest" status="DEBUG">
- <Appenders>
- <List name="TestAppender"/>
- <List name="StringAppender">
- <PatternLayout pattern="%class"/>
- </List>
- <Console name="Console" target="SYSTEM_ERR">
- <BasicLayout/>
- </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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/pom.xml b/log4j-jul/pom.xml
new file mode 100644
index 0000000..e8dc0f2
--- /dev/null
+++ b/log4j-jul/pom.xml
@@ -0,0 +1,75 @@
+<?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>2.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>log4j-jul</artifactId>
+ <name>Log4j JUL Adaptor</name>
+ <description>Log4j implementation of java.util.logging</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>
+ <optional>true</optional>
+ </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>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.logging.log4j.jdk</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..29f0aa0
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.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
+ *
+ */
+public abstract class AbstractLoggerAdapter extends org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
+
+ public 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/c02b66be/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
new file mode 100644
index 0000000..6beffc9
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+/**
+ * Consult the documentation for your Log4j Provider for more details.
+ * this implementation. If you need support for these methods, then you'll need to use log4j-core.</p>
+ */
+public class ApiLogger extends Logger {
+
+ private static final String FQCN = java.util.logging.Logger.class.getName();
+
+ private static final String PREFIX = "log4j.jul.";
+
+ /**
+ */
+ public static final String THREAD_ID = PREFIX + "threadID";
+
+ /**
+ */
+ public static final String SEQUENCE_NUMBER = PREFIX + "sequenceNumber";
+
+ /**
+ * for custom Level implementations as well as for obtaining the exact Level that was used rather than the
+ */
+ 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;
+ }
+
+ 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);
+ }
+
+ public boolean isLoggable(final Level level) {
+ return logger.isEnabled(Levels.toLevel(level));
+ }
+
+ public String getName() {
+ return logger.getName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..6b3cd65
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ * not available.
+ *
+ */
+public class ApiLoggerAdapter extends AbstractLoggerAdapter {
+ public 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/c02b66be/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
new file mode 100644
index 0000000..60ff82f
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ */
+public class CoreLogger extends ApiLogger {
+
+ private final org.apache.logging.log4j.core.Logger logger;
+
+ /**
+ *
+ */
+ CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
+ super(logger);
+ this.logger = logger;
+ }
+
+ public void setLevel(final Level level) throws SecurityException {
+ logger.setLevel(Levels.toLevel(level));
+ super.setLevel(level);
+ }
+
+ /**
+ *
+ */
+ public synchronized void setUseParentHandlers(final boolean additive) {
+ logger.setAdditive(additive);
+ }
+
+ /**
+ * Log4j version of JDK Loggers do <em>not</em> use Handlers.</strong>
+ *
+ */
+ public synchronized boolean getUseParentHandlers() {
+ return logger.isAdditive();
+ }
+
+ 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/c02b66be/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
new file mode 100644
index 0000000..d91eae1
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ *
+ */
+public class CoreLoggerAdapter extends AbstractLoggerAdapter {
+
+ public 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/c02b66be/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
new file mode 100644
index 0000000..50354f7
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import org.apache.logging.log4j.Level;
+
+/**
+ * Utility class to convert between JDK Levels and Log4j 2 Levels.
+ *
+ */
+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.
+ *
+ */
+ 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.
+ *
+ */
+ 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/c02b66be/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
new file mode 100644
index 0000000..8d2ae43
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.LoggerAdapter;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+
+/**
+ *
+ */
+public class LogManager extends java.util.logging.LogManager {
+
+ private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
+ private static final LoggerAdapter<Logger> ADAPTER;
+
+ static {
+ // find out if log4j-core is available
+ String registryClassName;
+ try {
+ LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
+ registryClassName = "org.apache.logging.log4j.jdk.CoreLoggerRegistry";
+ } catch (final ClassNotFoundException ignored) {
+ registryClassName = "org.apache.logging.log4j.jdk.ApiLoggerRegistry";
+ }
+ LOGGER.debug("Attempting to use {}", registryClassName);
+ try {
+ ADAPTER = LoaderUtil.newCheckedInstanceOf(registryClassName, AbstractLoggerAdapter.class);
+ } catch (final Exception e) {
+ throw LOGGER.throwing(new ExceptionInInitializerError(e));
+ }
+ }
+
+ public LogManager() {
+ super();
+ LOGGER.info("Registered Log4j as the java.util.logging.LogManager.");
+ }
+
+ 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;
+ }
+
+ public Logger getLogger(final String name) {
+ LOGGER.trace("Call to LogManager.getLogger({})", name);
+ return ADAPTER.getLogger(name);
+ }
+
+ public Enumeration<String> getLoggerNames() {
+ return Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/src/site/site.xml b/log4j-jul/src/site/site.xml
new file mode 100644
index 0000000..f8c7307
--- /dev/null
+++ b/log4j-jul/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 Logging Adaptor"
+ 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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..0b21372
--- /dev/null
+++ b/log4j-jul/src/site/xdoc/index.xml
@@ -0,0 +1,168 @@
+<?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.
+-->
+
+<!DOCTYPE document [<!ENTITY le "&#x2264;">]>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>Log4j JDK Logging Adaptor</title>
+ </properties>
+ <body>
+ <section name="JDK Logging Adaptor">
+ <p>
+ The JDK Logging Adaptor is a custom implementation of
+ <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogManager.html">java.util.logging.LogManager</a>
+ that uses <a href="../log4j-core/index.html">Log4j</a>.
+ </p>
+ </section>
+ <section name="Requirements">
+ <p>
+ The JDK Logging Adaptor requires at least Java 6 and is dependent on the Log4j API and Log4j Core.
+ </p>
+ </section>
+ <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>
+ </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>System.setProperty()</code> before any calls are made to <code>LogManager</code> or <code>Logger</code>.
+ </p>
+ </section>
+ <section name="Compatibility">
+ <p>
+ The use of a
+ <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Filter.html">java.util.logging.Filter</a>
+ is supported on a per-<a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html">Logger</a>
+ basis. However, it is recommended to use the standard <a href="../manual/filters.html">Filters</a> feature in
+ Log4j instead.
+ </p>
+ <p>
+ The use of
+ <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html">java.util.logging.Handler</a>
+ classes is <em>NOT</em> supported. Custom Handlers should instead use an appropriate
+ <a href="../manual/appenders.html">Appender</a> or code their own
+ <a class="javadoc" href="../log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
+ plugin.
+ </p>
+ <p>
+ Java logging levels are translated into Log4j logging levels dynamically. The following table lists the
+ conversions between a Java logging level and its equivalent Log4j level.
+ </p>
+ <table>
+ <caption>Level conversions</caption>
+ <thead>
+ <tr>
+ <th>Java Level</th>
+ <th>Level Range</th>
+ <th>Log4j Level</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#OFF">OFF</a></td>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE">Integer.MAX_VALUE</a></td>
+ <td>OFF</td>
+ </tr>
+ <tr>
+ <td class="muted">n/a</td>
+ <td>1000 &lt; <var>level</var> &lt; <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE">Integer.MAX_VALUE</a></td>
+ <td>FATAL</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#SEVERE">SEVERE</a></td>
+ <td>900 &lt; <var>level</var> &le; 1000</td>
+ <td>ERROR</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#WARNING">WARNING</a></td>
+ <td>800 &lt; <var>level</var> &le; 900</td>
+ <td>WARN</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#INFO">INFO</a></td>
+ <td>700 &lt; <var>level</var> &le; 800</td>
+ <td>INFO</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#CONFIG">CONFIG</a></td>
+ <td>500 &lt; <var>level</var> &le; 700</td>
+ <td>INFO</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINE">FINE</a></td>
+ <td>400 &lt; <var>level</var> &le; 500</td>
+ <td>DEBUG</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINER">FINER</a></td>
+ <td>300 &lt; <var>level</var> &le; 400</td>
+ <td>DEBUG</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINEST">FINEST</a></td>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a> &lt; <var>level</var> &le; 300</td>
+ <td>TRACE</td>
+ </tr>
+ <tr>
+ <td>ALL</td>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a></td>
+ <td>ALL</td>
+ </tr>
+ </tbody>
+ </table>
+ <p>
+ There are currently three additional pieces of information obtained from each
+ <a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a>
+ that are stored in the <a href="../manual/thread-context.html">ThreadContext</a>.
+ </p>
+ <table>
+ <caption>ThreadContext map keys</caption>
+ <thead>
+ <tr>
+ <th>Key</th>
+ <th><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a> Property</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>log4j.jul.threadID</td>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getThreadID%28%29">threadID</a></td>
+ <td>An identifier for the thread where the message originated.</td>
+ </tr>
+ <tr>
+ <td>log4j.jul.sequenceNumber</td>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getSequenceNumber%28%29">sequenceNumber</a></td>
+ <td>A unique, increasing sequence number generated by the LogRecord constructor.</td>
+ </tr>
+ <tr>
+ <td>log4j.jul.level</td>
+ <td><a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getLevel%28%29">level</a></td>
+ <td>The logging message level name. This level is translated into an equivalent Log4j level, so the original
+ logging level name is saved here.</td>
+ </tr>
+ </tbody>
+ </table>
+ </section>
+ </body>
+</document>
\ No newline at end of file
Matt Sicker
2014-09-07 22:17:15 UTC
Permalink
Good catch. I'll get that in my branch. I don't really want to push it at
the moment as I merged from master and now it'd be like 100 emails.
Post by Remko Popma
Sorry for nagging, but should the package be called jul instead of jdk?
Sent from my iPhone
Fix directory structure.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c02b66be
http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c02b66be
http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c02b66be
Branch: refs/heads/LOG4J2-608
Commit: c02b66be95ade10e5535bb6f48bd2298aac48895
Parents: 228da65
Authored: Sun Sep 7 13:49:29 2014 -0500
Committed: Sun Sep 7 13:53:10 2014 -0500
----------------------------------------------------------------------
log4j-jul/log4j-jdk/pom.xml | 75 ---------
.../log4j/jdk/AbstractLoggerAdapter.java | 44 -----
.../org/apache/logging/log4j/jdk/ApiLogger.java | 100 -----------
.../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 | 80 ---------
log4j-jul/log4j-jdk/src/site/site.xml | 52 ------
log4j-jul/log4j-jdk/src/site/xdoc/index.xml | 168 -------------------
.../logging/log4j/jdk/CoreLoggerTest.java | 101 -----------
.../logging/log4j/jdk/CustomJdkLevel.java | 40 -----
.../apache/logging/log4j/jdk/LevelsTest.java | 49 ------
.../src/test/resources/log4j2-test.xml | 39 -----
log4j-jul/pom.xml | 75 +++++++++
.../log4j/jdk/AbstractLoggerAdapter.java | 44 +++++
.../org/apache/logging/log4j/jdk/ApiLogger.java | 100 +++++++++++
.../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 | 80 +++++++++
log4j-jul/src/site/site.xml | 52 ++++++
log4j-jul/src/site/xdoc/index.xml | 168 +++++++++++++++++++
.../logging/log4j/jdk/CoreLoggerTest.java | 101 +++++++++++
.../logging/log4j/jdk/CustomJdkLevel.java | 40 +++++
.../apache/logging/log4j/jdk/LevelsTest.java | 49 ++++++
log4j-jul/src/test/resources/log4j2-test.xml | 39 +++++
28 files changed, 1006 insertions(+), 1006 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/pom.xml b/log4j-jul/log4j-jdk/pom.xml
deleted file mode 100644
index e8dc0f2..0000000
--- a/log4j-jul/log4j-jdk/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?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>2.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>log4j-jul</artifactId>
- <name>Log4j JUL Adaptor</name>
- <description>Log4j implementation of java.util.logging</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>
- <optional>true</optional>
- </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>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
-
<Export-Package>org.apache.logging.log4j.jdk</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
deleted file mode 100644
index 29f0aa0..0000000
---
a/log4j-jul/log4j-jdk/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
- *
- */
-public abstract class AbstractLoggerAdapter extends
org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
-
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
deleted file mode 100644
index 6beffc9..0000000
---
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
+++ /dev/null
@@ -1,100 +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;
-
-/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
be implemented in one of many different ways.
- * Consult the documentation for your Log4j Provider for more details.
#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>
- */
-public class ApiLogger extends Logger {
-
- private static final String FQCN =
java.util.logging.Logger.class.getName();
-
- private static final String PREFIX = "log4j.jul.";
-
- /**
- */
- public static final String THREAD_ID = PREFIX + "threadID";
-
- /**
stored.
- */
- public static final String SEQUENCE_NUMBER = PREFIX +
"sequenceNumber";
-
- /**
particularly useful
- * for custom Level implementations as well as for obtaining the
exact Level that was used rather than the
- */
- 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;
- }
-
- 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);
- }
-
- public boolean isLoggable(final Level level) {
- return logger.isEnabled(Levels.toLevel(level));
- }
-
- public String getName() {
- return logger.getName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
deleted file mode 100644
index 6b3cd65..0000000
---
a/log4j-jul/log4j-jdk/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;
-
-/**
the fallback registry used when log4j-core is
- * not available.
- *
- */
-public class ApiLoggerAdapter extends AbstractLoggerAdapter {
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
deleted file mode 100644
index 60ff82f..0000000
---
a/log4j-jul/log4j-jdk/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;
-
-/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
uses
- *
- */
-public class CoreLogger extends ApiLogger {
-
- private final org.apache.logging.log4j.core.Logger logger;
-
- /**
org.apache.logging.log4j.core.Logger}.
- *
- */
- CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
- super(logger);
- this.logger = logger;
- }
-
- public void setLevel(final Level level) throws SecurityException {
- logger.setLevel(Levels.toLevel(level));
- super.setLevel(level);
- }
-
- /**
org.apache.logging.log4j.core.Logger} as additive.
- *
- */
- public synchronized void setUseParentHandlers(final boolean
additive) {
- logger.setAdditive(additive);
- }
-
- /**
org.apache.logging.log4j.core.Logger} is additive. <strong>Note that the
- * Log4j version of JDK Loggers do <em>not</em> use
Handlers.</strong>
- *
false} otherwise
- */
- public synchronized boolean getUseParentHandlers() {
- return logger.isAdditive();
- }
-
- public Logger getParent() {
- final org.apache.logging.log4j.core.Logger parent =
logger.getParent();
Logger.getLogger(parent.getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
deleted file mode 100644
index d91eae1..0000000
---
a/log4j-jul/log4j-jdk/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;
-
-/**
- *
- */
-public class CoreLoggerAdapter extends AbstractLoggerAdapter {
-
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
deleted file mode 100644
index 50354f7..0000000
---
a/log4j-jul/log4j-jdk/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.
- *
- */
-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.
- *
- */
- 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.
- *
- */
- 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
deleted file mode 100644
index 8d2ae43..0000000
---
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
+++ /dev/null
@@ -1,80 +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.spi.LoggerAdapter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
that the system property
org.apache.logging.log4j.jdk.LogManager} in order to use
java.util.logging.Logger} are supported.
- *
- */
-public class LogManager extends java.util.logging.LogManager {
-
- private static final org.apache.logging.log4j.Logger LOGGER =
StatusLogger.getLogger();
- private static final LoggerAdapter<Logger> ADAPTER;
-
- static {
- // find out if log4j-core is available
- String registryClassName;
- try {
-
LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
- registryClassName =
"org.apache.logging.log4j.jdk.CoreLoggerRegistry";
- } catch (final ClassNotFoundException ignored) {
- registryClassName =
"org.apache.logging.log4j.jdk.ApiLoggerRegistry";
- }
- LOGGER.debug("Attempting to use {}", registryClassName);
- try {
- ADAPTER =
LoaderUtil.newCheckedInstanceOf(registryClassName,
AbstractLoggerAdapter.class);
- } catch (final Exception e) {
- throw LOGGER.throwing(new ExceptionInInitializerError(e));
- }
- }
-
- public LogManager() {
- super();
- LOGGER.info("Registered Log4j as the
java.util.logging.LogManager.");
- }
-
- 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;
- }
-
- public Logger getLogger(final String name) {
- LOGGER.trace("Call to LogManager.getLogger({})", name);
- return ADAPTER.getLogger(name);
- }
-
- public Enumeration<String> getLoggerNames() {
- return
Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/site/site.xml
b/log4j-jul/log4j-jdk/src/site/site.xml
deleted file mode 100644
index f8c7307..0000000
--- a/log4j-jul/log4j-jdk/src/site/site.xml
+++ /dev/null
@@ -1,52 +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.
-
--->
-<project name="Log4j JDK Logging Adaptor"
- 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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
b/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
deleted file mode 100644
index 0b21372..0000000
--- a/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<?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.
--->
-
-<!DOCTYPE document [<!ENTITY le "&#x2264;">]>
-<document xmlns="http://maven.apache.org/XDOC/2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
- <properties>
- <title>Log4j JDK Logging Adaptor</title>
- </properties>
- <body>
- <section name="JDK Logging Adaptor">
- <p>
- The JDK Logging Adaptor is a custom implementation of
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogManager.html
">java.util.logging.LogManager</a>
- that uses <a href="../log4j-core/index.html">Log4j</a>.
- </p>
- </section>
- <section name="Requirements">
- <p>
- The JDK Logging Adaptor requires at least Java 6 and is
dependent on the Log4j API and Log4j Core.
- </p>
- </section>
- <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>
- </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>System.setProperty()</code> before any calls are made to
<code>LogManager</code> or <code>Logger</code>.
- </p>
- </section>
- <section name="Compatibility">
- <p>
- The use of a
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Filter.html
">java.util.logging.Filter</a>
- is supported on a per-<a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html
">Logger</a>
- basis. However, it is recommended to use the standard <a
href="../manual/filters.html">Filters</a> feature in
- Log4j instead.
- </p>
- <p>
- The use of
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html
">java.util.logging.Handler</a>
- classes is <em>NOT</em> supported. Custom Handlers should
instead use an appropriate
- <a href="../manual/appenders.html">Appender</a> or code their
own
- <a class="javadoc"
href="../log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
- plugin.
- </p>
- <p>
- Java logging levels are translated into Log4j logging levels
dynamically. The following table lists the
- conversions between a Java logging level and its equivalent
Log4j level.
- </p>
- <table>
- <caption>Level conversions</caption>
- <thead>
- <tr>
- <th>Java Level</th>
- <th>Level Range</th>
- <th>Log4j Level</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#OFF
">OFF</a></td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
- <td>OFF</td>
- </tr>
- <tr>
- <td class="muted">n/a</td>
- <td>1000 &lt; <var>level</var> &lt; <a class="javadoc"
href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
- <td>FATAL</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#SEVERE
">SEVERE</a></td>
- <td>900 &lt; <var>level</var> &le; 1000</td>
- <td>ERROR</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#WARNING
">WARNING</a></td>
- <td>800 &lt; <var>level</var> &le; 900</td>
- <td>WARN</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#INFO
">INFO</a></td>
- <td>700 &lt; <var>level</var> &le; 800</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#CONFIG
">CONFIG</a></td>
- <td>500 &lt; <var>level</var> &le; 700</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINE
">FINE</a></td>
- <td>400 &lt; <var>level</var> &le; 500</td>
- <td>DEBUG</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINER
">FINER</a></td>
- <td>300 &lt; <var>level</var> &le; 400</td>
- <td>DEBUG</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINEST
">FINEST</a></td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a>
&lt; <var>level</var> &le; 300</td>
- <td>TRACE</td>
- </tr>
- <tr>
- <td>ALL</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE
">Integer.MIN_VALUE</a></td>
- <td>ALL</td>
- </tr>
- </tbody>
- </table>
- <p>
- There are currently three additional pieces of information
obtained from each
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html
">LogRecord</a>
- that are stored in the <a
href="../manual/thread-context.html">ThreadContext</a>.
- </p>
- <table>
- <caption>ThreadContext map keys</caption>
- <thead>
- <tr>
- <th>Key</th>
- <th><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a>
Property</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>log4j.jul.threadID</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getThreadID%28%29
">threadID</a></td>
- <td>An identifier for the thread where the message
originated.</td>
- </tr>
- <tr>
- <td>log4j.jul.sequenceNumber</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getSequenceNumber%28%29
">sequenceNumber</a></td>
- <td>A unique, increasing sequence number generated by the
LogRecord constructor.</td>
- </tr>
- <tr>
- <td>log4j.jul.level</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getLevel%28%29
">level</a></td>
- <td>The logging message level name. This level is
translated into an equivalent Log4j level, so the original
- logging level name is saved here.</td>
- </tr>
- </tbody>
- </table>
- </section>
- </body>
-</document>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
deleted file mode 100644
index 16d5831..0000000
---
a/log4j-jul/log4j-jdk/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;
-
- public static void setUpClass() {
- System.setProperty("java.util.logging.manager",
LogManager.class.getName());
- }
-
- 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");
- }
-
- public void tearDown() throws Exception {
- eventAppender.clear();
- }
-
- 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());
- }
-
- 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);
- }
-
- 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()));
- }
-
- public void testSetLevel() throws Exception {
- logger.setLevel(java.util.logging.Level.SEVERE);
- assertThat(logger.getLevel(),
equalTo(java.util.logging.Level.SEVERE));
- }
-
- public void testIsLoggable() throws Exception {
- assertThat(logger.isLoggable(java.util.logging.Level.SEVERE),
equalTo(true));
- assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1),
equalTo(true));
- }
-
- public void testGetName() throws Exception {
- assertThat(logger.getName(), equalTo(LOGGER_NAME));
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
deleted file mode 100644
index d125d0e..0000000
---
a/log4j-jul/log4j-jdk/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/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
deleted file mode 100644
index b4a6056..0000000
---
a/log4j-jul/log4j-jdk/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.*;
-
-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;
- }
-
- 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}
- }
- );
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
b/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
deleted file mode 100644
index af6a050..0000000
--- a/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,39 +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.
- -->
-
-<Configuration name="LoggerTest" status="DEBUG">
- <Appenders>
- <List name="TestAppender"/>
- <List name="StringAppender">
- <PatternLayout pattern="%class"/>
- </List>
- <Console name="Console" target="SYSTEM_ERR">
- <BasicLayout/>
- </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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/pom.xml b/log4j-jul/pom.xml
new file mode 100644
index 0000000..e8dc0f2
--- /dev/null
+++ b/log4j-jul/pom.xml
@@ -0,0 +1,75 @@
+<?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>2.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>log4j-jul</artifactId>
+ <name>Log4j JUL Adaptor</name>
+ <description>Log4j implementation of java.util.logging</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>
+ <optional>true</optional>
+ </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>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+
<Export-Package>org.apache.logging.log4j.jdk</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..29f0aa0
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.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
+ *
+ */
+public abstract class AbstractLoggerAdapter extends
org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
+
+ public 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/c02b66be/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
new file mode 100644
index 0000000..6beffc9
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
be implemented in one of many different ways.
+ * Consult the documentation for your Log4j Provider for more details.
#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>
+ */
+public class ApiLogger extends Logger {
+
+ private static final String FQCN =
java.util.logging.Logger.class.getName();
+
+ private static final String PREFIX = "log4j.jul.";
+
+ /**
+ */
+ public static final String THREAD_ID = PREFIX + "threadID";
+
+ /**
stored.
+ */
+ public static final String SEQUENCE_NUMBER = PREFIX +
"sequenceNumber";
+
+ /**
particularly useful
+ * for custom Level implementations as well as for obtaining the
exact Level that was used rather than the
+ */
+ 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;
+ }
+
+ 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);
+ }
+
+ public boolean isLoggable(final Level level) {
+ return logger.isEnabled(Levels.toLevel(level));
+ }
+
+ public String getName() {
+ return logger.getName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..6b3cd65
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
the fallback registry used when log4j-core is
+ * not available.
+ *
+ */
+public class ApiLoggerAdapter extends AbstractLoggerAdapter {
+ public 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/c02b66be/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
new file mode 100644
index 0000000..60ff82f
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
uses
+ *
+ */
+public class CoreLogger extends ApiLogger {
+
+ private final org.apache.logging.log4j.core.Logger logger;
+
+ /**
org.apache.logging.log4j.core.Logger}.
+ *
+ */
+ CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
+ super(logger);
+ this.logger = logger;
+ }
+
+ public void setLevel(final Level level) throws SecurityException {
+ logger.setLevel(Levels.toLevel(level));
+ super.setLevel(level);
+ }
+
+ /**
org.apache.logging.log4j.core.Logger} as additive.
+ *
+ */
+ public synchronized void setUseParentHandlers(final boolean
additive) {
+ logger.setAdditive(additive);
+ }
+
+ /**
org.apache.logging.log4j.core.Logger} is additive. <strong>Note that the
+ * Log4j version of JDK Loggers do <em>not</em> use
Handlers.</strong>
+ *
false} otherwise
+ */
+ public synchronized boolean getUseParentHandlers() {
+ return logger.isAdditive();
+ }
+
+ public Logger getParent() {
+ final org.apache.logging.log4j.core.Logger parent =
logger.getParent();
Logger.getLogger(parent.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..d91eae1
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ *
+ */
+public class CoreLoggerAdapter extends AbstractLoggerAdapter {
+
+ public 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/c02b66be/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
new file mode 100644
index 0000000..50354f7
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import org.apache.logging.log4j.Level;
+
+/**
+ * Utility class to convert between JDK Levels and Log4j 2 Levels.
+ *
+ */
+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.
+ *
+ */
+ 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.
+ *
+ */
+ 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/c02b66be/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
new file mode 100644
index 0000000..8d2ae43
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.LoggerAdapter;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+
+/**
that the system property
org.apache.logging.log4j.jdk.LogManager} in order to use
java.util.logging.Logger} are supported.
+ *
+ */
+public class LogManager extends java.util.logging.LogManager {
+
+ private static final org.apache.logging.log4j.Logger LOGGER =
StatusLogger.getLogger();
+ private static final LoggerAdapter<Logger> ADAPTER;
+
+ static {
+ // find out if log4j-core is available
+ String registryClassName;
+ try {
+
LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
+ registryClassName =
"org.apache.logging.log4j.jdk.CoreLoggerRegistry";
+ } catch (final ClassNotFoundException ignored) {
+ registryClassName =
"org.apache.logging.log4j.jdk.ApiLoggerRegistry";
+ }
+ LOGGER.debug("Attempting to use {}", registryClassName);
+ try {
+ ADAPTER =
LoaderUtil.newCheckedInstanceOf(registryClassName,
AbstractLoggerAdapter.class);
+ } catch (final Exception e) {
+ throw LOGGER.throwing(new ExceptionInInitializerError(e));
+ }
+ }
+
+ public LogManager() {
+ super();
+ LOGGER.info("Registered Log4j as the
java.util.logging.LogManager.");
+ }
+
+ 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;
+ }
+
+ public Logger getLogger(final String name) {
+ LOGGER.trace("Call to LogManager.getLogger({})", name);
+ return ADAPTER.getLogger(name);
+ }
+
+ public Enumeration<String> getLoggerNames() {
+ return
Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/src/site/site.xml b/log4j-jul/src/site/site.xml
new file mode 100644
index 0000000..f8c7307
--- /dev/null
+++ b/log4j-jul/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 Logging Adaptor"
+ 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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..0b21372
--- /dev/null
+++ b/log4j-jul/src/site/xdoc/index.xml
@@ -0,0 +1,168 @@
+<?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.
+-->
+
+<!DOCTYPE document [<!ENTITY le "&#x2264;">]>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>Log4j JDK Logging Adaptor</title>
+ </properties>
+ <body>
+ <section name="JDK Logging Adaptor">
+ <p>
+ The JDK Logging Adaptor is a custom implementation of
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogManager.html
">java.util.logging.LogManager</a>
+ that uses <a href="../log4j-core/index.html">Log4j</a>.
+ </p>
+ </section>
+ <section name="Requirements">
+ <p>
+ The JDK Logging Adaptor requires at least Java 6 and is
dependent on the Log4j API and Log4j Core.
+ </p>
+ </section>
+ <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>
+ </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>System.setProperty()</code> before any calls are made to
<code>LogManager</code> or <code>Logger</code>.
+ </p>
+ </section>
+ <section name="Compatibility">
+ <p>
+ The use of a
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Filter.html
">java.util.logging.Filter</a>
+ is supported on a per-<a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html
">Logger</a>
+ basis. However, it is recommended to use the standard <a
href="../manual/filters.html">Filters</a> feature in
+ Log4j instead.
+ </p>
+ <p>
+ The use of
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html
">java.util.logging.Handler</a>
+ classes is <em>NOT</em> supported. Custom Handlers should
instead use an appropriate
+ <a href="../manual/appenders.html">Appender</a> or code their
own
+ <a class="javadoc"
href="../log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
+ plugin.
+ </p>
+ <p>
+ Java logging levels are translated into Log4j logging levels
dynamically. The following table lists the
+ conversions between a Java logging level and its equivalent
Log4j level.
+ </p>
+ <table>
+ <caption>Level conversions</caption>
+ <thead>
+ <tr>
+ <th>Java Level</th>
+ <th>Level Range</th>
+ <th>Log4j Level</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#OFF
">OFF</a></td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
+ <td>OFF</td>
+ </tr>
+ <tr>
+ <td class="muted">n/a</td>
+ <td>1000 &lt; <var>level</var> &lt; <a class="javadoc"
href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
+ <td>FATAL</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#SEVERE
">SEVERE</a></td>
+ <td>900 &lt; <var>level</var> &le; 1000</td>
+ <td>ERROR</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#WARNING
">WARNING</a></td>
+ <td>800 &lt; <var>level</var> &le; 900</td>
+ <td>WARN</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#INFO
">INFO</a></td>
+ <td>700 &lt; <var>level</var> &le; 800</td>
+ <td>INFO</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#CONFIG
">CONFIG</a></td>
+ <td>500 &lt; <var>level</var> &le; 700</td>
+ <td>INFO</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINE
">FINE</a></td>
+ <td>400 &lt; <var>level</var> &le; 500</td>
+ <td>DEBUG</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINER
">FINER</a></td>
+ <td>300 &lt; <var>level</var> &le; 400</td>
+ <td>DEBUG</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINEST
">FINEST</a></td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a>
&lt; <var>level</var> &le; 300</td>
+ <td>TRACE</td>
+ </tr>
+ <tr>
+ <td>ALL</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE
">Integer.MIN_VALUE</a></td>
+ <td>ALL</td>
+ </tr>
+ </tbody>
+ </table>
+ <p>
+ There are currently three additional pieces of information
obtained from each
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html
">LogRecord</a>
+ that are stored in the <a
href="../manual/thread-context.html">ThreadContext</a>.
+ </p>
+ <table>
+ <caption>ThreadContext map keys</caption>
+ <thead>
+ <tr>
+ <th>Key</th>
+ <th><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a>
Property</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>log4j.jul.threadID</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getThreadID%28%29
">threadID</a></td>
+ <td>An identifier for the thread where the message
originated.</td>
+ </tr>
+ <tr>
+ <td>log4j.jul.sequenceNumber</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getSequenceNumber%28%29
">sequenceNumber</a></td>
+ <td>A unique, increasing sequence number generated by the
LogRecord constructor.</td>
+ </tr>
+ <tr>
+ <td>log4j.jul.level</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getLevel%28%29
">level</a></td>
+ <td>The logging message level name. This level is
translated into an equivalent Log4j level, so the original
+ logging level name is saved here.</td>
+ </tr>
+ </tbody>
+ </table>
+ </section>
+ </body>
+</document>
\ No newline at end of file
---------------------------------------------------------------------
--
Matt Sicker <***@gmail.com>
Matt Sicker
2014-09-07 22:42:09 UTC
Permalink
Alright, pushed. I merged the branch to master as everything is done now.
Post by Matt Sicker
Good catch. I'll get that in my branch. I don't really want to push it at
the moment as I merged from master and now it'd be like 100 emails.
Post by Remko Popma
Sorry for nagging, but should the package be called jul instead of jdk?
Sent from my iPhone
Fix directory structure.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c02b66be
http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c02b66be
http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c02b66be
Branch: refs/heads/LOG4J2-608
Commit: c02b66be95ade10e5535bb6f48bd2298aac48895
Parents: 228da65
Authored: Sun Sep 7 13:49:29 2014 -0500
Committed: Sun Sep 7 13:53:10 2014 -0500
----------------------------------------------------------------------
log4j-jul/log4j-jdk/pom.xml | 75 ---------
.../log4j/jdk/AbstractLoggerAdapter.java | 44 -----
.../org/apache/logging/log4j/jdk/ApiLogger.java | 100 -----------
.../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 | 80 ---------
log4j-jul/log4j-jdk/src/site/site.xml | 52 ------
log4j-jul/log4j-jdk/src/site/xdoc/index.xml | 168
-------------------
.../logging/log4j/jdk/CoreLoggerTest.java | 101 -----------
.../logging/log4j/jdk/CustomJdkLevel.java | 40 -----
.../apache/logging/log4j/jdk/LevelsTest.java | 49 ------
.../src/test/resources/log4j2-test.xml | 39 -----
log4j-jul/pom.xml | 75 +++++++++
.../log4j/jdk/AbstractLoggerAdapter.java | 44 +++++
.../org/apache/logging/log4j/jdk/ApiLogger.java | 100 +++++++++++
.../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 | 80 +++++++++
log4j-jul/src/site/site.xml | 52 ++++++
log4j-jul/src/site/xdoc/index.xml | 168
+++++++++++++++++++
.../logging/log4j/jdk/CoreLoggerTest.java | 101 +++++++++++
.../logging/log4j/jdk/CustomJdkLevel.java | 40 +++++
.../apache/logging/log4j/jdk/LevelsTest.java | 49 ++++++
log4j-jul/src/test/resources/log4j2-test.xml | 39 +++++
28 files changed, 1006 insertions(+), 1006 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/pom.xml b/log4j-jul/log4j-jdk/pom.xml
deleted file mode 100644
index e8dc0f2..0000000
--- a/log4j-jul/log4j-jdk/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?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>2.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>log4j-jul</artifactId>
- <name>Log4j JUL Adaptor</name>
- <description>Log4j implementation of java.util.logging</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>
- <optional>true</optional>
- </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>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
-
<Export-Package>org.apache.logging.log4j.jdk</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
deleted file mode 100644
index 29f0aa0..0000000
---
a/log4j-jul/log4j-jdk/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
- *
- */
-public abstract class AbstractLoggerAdapter extends
org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
-
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
deleted file mode 100644
index 6beffc9..0000000
---
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
+++ /dev/null
@@ -1,100 +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;
-
-/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
be implemented in one of many different ways.
- * Consult the documentation for your Log4j Provider for more details.
#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>
- */
-public class ApiLogger extends Logger {
-
- private static final String FQCN =
java.util.logging.Logger.class.getName();
-
- private static final String PREFIX = "log4j.jul.";
-
- /**
stored.
- */
- public static final String THREAD_ID = PREFIX + "threadID";
-
- /**
be stored.
- */
- public static final String SEQUENCE_NUMBER = PREFIX +
"sequenceNumber";
-
- /**
particularly useful
- * for custom Level implementations as well as for obtaining the
exact Level that was used rather than the
- */
- 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;
- }
-
- 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);
- }
-
- public boolean isLoggable(final Level level) {
- return logger.isEnabled(Levels.toLevel(level));
- }
-
- public String getName() {
- return logger.getName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
deleted file mode 100644
index 6b3cd65..0000000
---
a/log4j-jul/log4j-jdk/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;
-
-/**
is the fallback registry used when log4j-core is
- * not available.
- *
- */
-public class ApiLoggerAdapter extends AbstractLoggerAdapter {
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLogger.java
deleted file mode 100644
index 60ff82f..0000000
---
a/log4j-jul/log4j-jdk/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;
-
-/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
uses
- *
- */
-public class CoreLogger extends ApiLogger {
-
- private final org.apache.logging.log4j.core.Logger logger;
-
- /**
org.apache.logging.log4j.core.Logger}.
- *
- */
- CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
- super(logger);
- this.logger = logger;
- }
-
- public void setLevel(final Level level) throws SecurityException {
- logger.setLevel(Levels.toLevel(level));
- super.setLevel(level);
- }
-
- /**
org.apache.logging.log4j.core.Logger} as additive.
- *
- */
- public synchronized void setUseParentHandlers(final boolean
additive) {
- logger.setAdditive(additive);
- }
-
- /**
org.apache.logging.log4j.core.Logger} is additive. <strong>Note that the
- * Log4j version of JDK Loggers do <em>not</em> use
Handlers.</strong>
- *
false} otherwise
- */
- public synchronized boolean getUseParentHandlers() {
- return logger.isAdditive();
- }
-
- public Logger getParent() {
- final org.apache.logging.log4j.core.Logger parent =
logger.getParent();
Logger.getLogger(parent.getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
deleted file mode 100644
index d91eae1..0000000
---
a/log4j-jul/log4j-jdk/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;
-
-/**
- *
- */
-public class CoreLoggerAdapter extends AbstractLoggerAdapter {
-
- public 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/Levels.java
deleted file mode 100644
index 50354f7..0000000
---
a/log4j-jul/log4j-jdk/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.
- *
- */
-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.
- *
- */
- 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.
- *
- */
- 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/c02b66be/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
b/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
deleted file mode 100644
index 8d2ae43..0000000
---
a/log4j-jul/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
+++ /dev/null
@@ -1,80 +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.spi.LoggerAdapter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
that the system property
org.apache.logging.log4j.jdk.LogManager} in order to use
java.util.logging.Logger} are supported.
- *
- */
-public class LogManager extends java.util.logging.LogManager {
-
- private static final org.apache.logging.log4j.Logger LOGGER =
StatusLogger.getLogger();
- private static final LoggerAdapter<Logger> ADAPTER;
-
- static {
- // find out if log4j-core is available
- String registryClassName;
- try {
-
LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
- registryClassName =
"org.apache.logging.log4j.jdk.CoreLoggerRegistry";
- } catch (final ClassNotFoundException ignored) {
- registryClassName =
"org.apache.logging.log4j.jdk.ApiLoggerRegistry";
- }
- LOGGER.debug("Attempting to use {}", registryClassName);
- try {
- ADAPTER =
LoaderUtil.newCheckedInstanceOf(registryClassName,
AbstractLoggerAdapter.class);
- } catch (final Exception e) {
- throw LOGGER.throwing(new ExceptionInInitializerError(e));
- }
- }
-
- public LogManager() {
- super();
- LOGGER.info("Registered Log4j as the
java.util.logging.LogManager.");
- }
-
- 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;
- }
-
- public Logger getLogger(final String name) {
- LOGGER.trace("Call to LogManager.getLogger({})", name);
- return ADAPTER.getLogger(name);
- }
-
- public Enumeration<String> getLoggerNames() {
- return
Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/site/site.xml
b/log4j-jul/log4j-jdk/src/site/site.xml
deleted file mode 100644
index f8c7307..0000000
--- a/log4j-jul/log4j-jdk/src/site/site.xml
+++ /dev/null
@@ -1,52 +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.
-
--->
-<project name="Log4j JDK Logging Adaptor"
- 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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
b/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
deleted file mode 100644
index 0b21372..0000000
--- a/log4j-jul/log4j-jdk/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<?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.
--->
-
-<!DOCTYPE document [<!ENTITY le "&#x2264;">]>
-<document xmlns="http://maven.apache.org/XDOC/2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
- <properties>
- <title>Log4j JDK Logging Adaptor</title>
- </properties>
- <body>
- <section name="JDK Logging Adaptor">
- <p>
- The JDK Logging Adaptor is a custom implementation of
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogManager.html
">java.util.logging.LogManager</a>
- that uses <a href="../log4j-core/index.html">Log4j</a>.
- </p>
- </section>
- <section name="Requirements">
- <p>
- The JDK Logging Adaptor requires at least Java 6 and is
dependent on the Log4j API and Log4j Core.
- </p>
- </section>
- <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>
- </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>System.setProperty()</code> before any calls are made to
<code>LogManager</code> or <code>Logger</code>.
- </p>
- </section>
- <section name="Compatibility">
- <p>
- The use of a
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Filter.html
">java.util.logging.Filter</a>
- is supported on a per-<a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html
">Logger</a>
- basis. However, it is recommended to use the standard <a
href="../manual/filters.html">Filters</a> feature in
- Log4j instead.
- </p>
- <p>
- The use of
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html
">java.util.logging.Handler</a>
- classes is <em>NOT</em> supported. Custom Handlers should
instead use an appropriate
- <a href="../manual/appenders.html">Appender</a> or code their
own
- <a class="javadoc"
href="../log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
- plugin.
- </p>
- <p>
- Java logging levels are translated into Log4j logging levels
dynamically. The following table lists the
- conversions between a Java logging level and its equivalent
Log4j level.
- </p>
- <table>
- <caption>Level conversions</caption>
- <thead>
- <tr>
- <th>Java Level</th>
- <th>Level Range</th>
- <th>Log4j Level</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#OFF
">OFF</a></td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
- <td>OFF</td>
- </tr>
- <tr>
- <td class="muted">n/a</td>
- <td>1000 &lt; <var>level</var> &lt; <a class="javadoc"
href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
- <td>FATAL</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#SEVERE
">SEVERE</a></td>
- <td>900 &lt; <var>level</var> &le; 1000</td>
- <td>ERROR</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#WARNING
">WARNING</a></td>
- <td>800 &lt; <var>level</var> &le; 900</td>
- <td>WARN</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#INFO
">INFO</a></td>
- <td>700 &lt; <var>level</var> &le; 800</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#CONFIG
">CONFIG</a></td>
- <td>500 &lt; <var>level</var> &le; 700</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINE
">FINE</a></td>
- <td>400 &lt; <var>level</var> &le; 500</td>
- <td>DEBUG</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINER
">FINER</a></td>
- <td>300 &lt; <var>level</var> &le; 400</td>
- <td>DEBUG</td>
- </tr>
- <tr>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINEST
">FINEST</a></td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a>
&lt; <var>level</var> &le; 300</td>
- <td>TRACE</td>
- </tr>
- <tr>
- <td>ALL</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE
">Integer.MIN_VALUE</a></td>
- <td>ALL</td>
- </tr>
- </tbody>
- </table>
- <p>
- There are currently three additional pieces of information
obtained from each
- <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html
">LogRecord</a>
- that are stored in the <a
href="../manual/thread-context.html">ThreadContext</a>.
- </p>
- <table>
- <caption>ThreadContext map keys</caption>
- <thead>
- <tr>
- <th>Key</th>
- <th><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a>
Property</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>log4j.jul.threadID</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getThreadID%28%29
">threadID</a></td>
- <td>An identifier for the thread where the message
originated.</td>
- </tr>
- <tr>
- <td>log4j.jul.sequenceNumber</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getSequenceNumber%28%29
">sequenceNumber</a></td>
- <td>A unique, increasing sequence number generated by the
LogRecord constructor.</td>
- </tr>
- <tr>
- <td>log4j.jul.level</td>
- <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getLevel%28%29
">level</a></td>
- <td>The logging message level name. This level is
translated into an equivalent Log4j level, so the original
- logging level name is saved here.</td>
- </tr>
- </tbody>
- </table>
- </section>
- </body>
-</document>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CoreLoggerTest.java
deleted file mode 100644
index 16d5831..0000000
---
a/log4j-jul/log4j-jdk/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;
-
- public static void setUpClass() {
- System.setProperty("java.util.logging.manager",
LogManager.class.getName());
- }
-
- 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");
- }
-
- public void tearDown() throws Exception {
- eventAppender.clear();
- }
-
- 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());
- }
-
- 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);
- }
-
- 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()));
- }
-
- public void testSetLevel() throws Exception {
- logger.setLevel(java.util.logging.Level.SEVERE);
- assertThat(logger.getLevel(),
equalTo(java.util.logging.Level.SEVERE));
- }
-
- public void testIsLoggable() throws Exception {
- assertThat(logger.isLoggable(java.util.logging.Level.SEVERE),
equalTo(true));
- assertThat(logger.isLoggable(CustomJdkLevel.DEFCON_1),
equalTo(true));
- }
-
- public void testGetName() throws Exception {
- assertThat(logger.getName(), equalTo(LOGGER_NAME));
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/CustomJdkLevel.java
deleted file mode 100644
index d125d0e..0000000
---
a/log4j-jul/log4j-jdk/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/c02b66be/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
----------------------------------------------------------------------
diff --git
a/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
b/log4j-jul/log4j-jdk/src/test/java/org/apache/logging/log4j/jdk/LevelsTest.java
deleted file mode 100644
index b4a6056..0000000
---
a/log4j-jul/log4j-jdk/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.*;
-
-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;
- }
-
- 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}
- }
- );
- }
-
- 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/c02b66be/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
b/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
deleted file mode 100644
index af6a050..0000000
--- a/log4j-jul/log4j-jdk/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,39 +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.
- -->
-
-<Configuration name="LoggerTest" status="DEBUG">
- <Appenders>
- <List name="TestAppender"/>
- <List name="StringAppender">
- <PatternLayout pattern="%class"/>
- </List>
- <Console name="Console" target="SYSTEM_ERR">
- <BasicLayout/>
- </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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/pom.xml b/log4j-jul/pom.xml
new file mode 100644
index 0000000..e8dc0f2
--- /dev/null
+++ b/log4j-jul/pom.xml
@@ -0,0 +1,75 @@
+<?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>2.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>log4j-jul</artifactId>
+ <name>Log4j JUL Adaptor</name>
+ <description>Log4j implementation of java.util.logging</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>
+ <optional>true</optional>
+ </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>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+
<Export-Package>org.apache.logging.log4j.jdk</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..29f0aa0
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.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
+ *
+ */
+public abstract class AbstractLoggerAdapter extends
org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
+
+ public 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/c02b66be/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
new file mode 100644
index 0000000..6beffc9
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/ApiLogger.java
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
be implemented in one of many different ways.
+ * Consult the documentation for your Log4j Provider for more details.
#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>
+ */
+public class ApiLogger extends Logger {
+
+ private static final String FQCN =
java.util.logging.Logger.class.getName();
+
+ private static final String PREFIX = "log4j.jul.";
+
+ /**
stored.
+ */
+ public static final String THREAD_ID = PREFIX + "threadID";
+
+ /**
be stored.
+ */
+ public static final String SEQUENCE_NUMBER = PREFIX +
"sequenceNumber";
+
+ /**
particularly useful
+ * for custom Level implementations as well as for obtaining the
exact Level that was used rather than the
+ */
+ 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;
+ }
+
+ 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);
+ }
+
+ public boolean isLoggable(final Level level) {
+ return logger.isEnabled(Levels.toLevel(level));
+ }
+
+ public String getName() {
+ return logger.getName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..6b3cd65
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
is the fallback registry used when log4j-core is
+ * not available.
+ *
+ */
+public class ApiLoggerAdapter extends AbstractLoggerAdapter {
+ public 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/c02b66be/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
new file mode 100644
index 0000000..60ff82f
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
<strong>Note that this implementation does
class.</strong> Instead, logging is delegated to the
uses
+ *
+ */
+public class CoreLogger extends ApiLogger {
+
+ private final org.apache.logging.log4j.core.Logger logger;
+
+ /**
org.apache.logging.log4j.core.Logger}.
+ *
+ */
+ CoreLogger(final org.apache.logging.log4j.core.Logger logger) {
+ super(logger);
+ this.logger = logger;
+ }
+
+ public void setLevel(final Level level) throws SecurityException {
+ logger.setLevel(Levels.toLevel(level));
+ super.setLevel(level);
+ }
+
+ /**
org.apache.logging.log4j.core.Logger} as additive.
+ *
+ */
+ public synchronized void setUseParentHandlers(final boolean
additive) {
+ logger.setAdditive(additive);
+ }
+
+ /**
org.apache.logging.log4j.core.Logger} is additive. <strong>Note that the
+ * Log4j version of JDK Loggers do <em>not</em> use
Handlers.</strong>
+ *
false} otherwise
+ */
+ public synchronized boolean getUseParentHandlers() {
+ return logger.isAdditive();
+ }
+
+ public Logger getParent() {
+ final org.apache.logging.log4j.core.Logger parent =
logger.getParent();
Logger.getLogger(parent.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..d91eae1
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ *
+ */
+public class CoreLoggerAdapter extends AbstractLoggerAdapter {
+
+ public 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/c02b66be/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
new file mode 100644
index 0000000..50354f7
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/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.jdk;
+
+import org.apache.logging.log4j.Level;
+
+/**
+ * Utility class to convert between JDK Levels and Log4j 2 Levels.
+ *
+ */
+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.
+ *
+ */
+ 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.
+ *
+ */
+ 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/c02b66be/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
new file mode 100644
index 0000000..8d2ae43
--- /dev/null
+++
b/log4j-jul/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.LoggerAdapter;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+
+/**
that the system property
org.apache.logging.log4j.jdk.LogManager} in order to use
java.util.logging.Logger} are supported.
+ *
+ */
+public class LogManager extends java.util.logging.LogManager {
+
+ private static final org.apache.logging.log4j.Logger LOGGER =
StatusLogger.getLogger();
+ private static final LoggerAdapter<Logger> ADAPTER;
+
+ static {
+ // find out if log4j-core is available
+ String registryClassName;
+ try {
+
LoaderUtil.loadClass("org.apache.logging.log4j.core.Logger");
+ registryClassName =
"org.apache.logging.log4j.jdk.CoreLoggerRegistry";
+ } catch (final ClassNotFoundException ignored) {
+ registryClassName =
"org.apache.logging.log4j.jdk.ApiLoggerRegistry";
+ }
+ LOGGER.debug("Attempting to use {}", registryClassName);
+ try {
+ ADAPTER =
LoaderUtil.newCheckedInstanceOf(registryClassName,
AbstractLoggerAdapter.class);
+ } catch (final Exception e) {
+ throw LOGGER.throwing(new ExceptionInInitializerError(e));
+ }
+ }
+
+ public LogManager() {
+ super();
+ LOGGER.info("Registered Log4j as the
java.util.logging.LogManager.");
+ }
+
+ 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;
+ }
+
+ public Logger getLogger(final String name) {
+ LOGGER.trace("Call to LogManager.getLogger({})", name);
+ return ADAPTER.getLogger(name);
+ }
+
+ public Enumeration<String> getLoggerNames() {
+ return
Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/log4j-jul/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-jul/src/site/site.xml b/log4j-jul/src/site/site.xml
new file mode 100644
index 0000000..f8c7307
--- /dev/null
+++ b/log4j-jul/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 Logging Adaptor"
+ 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>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c02b66be/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
new file mode 100644
index 0000000..0b21372
--- /dev/null
+++ b/log4j-jul/src/site/xdoc/index.xml
@@ -0,0 +1,168 @@
+<?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.
+-->
+
+<!DOCTYPE document [<!ENTITY le "&#x2264;">]>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>Log4j JDK Logging Adaptor</title>
+ </properties>
+ <body>
+ <section name="JDK Logging Adaptor">
+ <p>
+ The JDK Logging Adaptor is a custom implementation of
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogManager.html
">java.util.logging.LogManager</a>
+ that uses <a href="../log4j-core/index.html">Log4j</a>.
+ </p>
+ </section>
+ <section name="Requirements">
+ <p>
+ The JDK Logging Adaptor requires at least Java 6 and is
dependent on the Log4j API and Log4j Core.
+ </p>
+ </section>
+ <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>
+ </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>System.setProperty()</code> before any calls are made to
<code>LogManager</code> or <code>Logger</code>.
+ </p>
+ </section>
+ <section name="Compatibility">
+ <p>
+ The use of a
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Filter.html
">java.util.logging.Filter</a>
+ is supported on a per-<a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html
">Logger</a>
+ basis. However, it is recommended to use the standard <a
href="../manual/filters.html">Filters</a> feature in
+ Log4j instead.
+ </p>
+ <p>
+ The use of
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html
">java.util.logging.Handler</a>
+ classes is <em>NOT</em> supported. Custom Handlers should
instead use an appropriate
+ <a href="../manual/appenders.html">Appender</a> or code their
own
+ <a class="javadoc"
href="../log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
+ plugin.
+ </p>
+ <p>
+ Java logging levels are translated into Log4j logging levels
dynamically. The following table lists the
+ conversions between a Java logging level and its equivalent
Log4j level.
+ </p>
+ <table>
+ <caption>Level conversions</caption>
+ <thead>
+ <tr>
+ <th>Java Level</th>
+ <th>Level Range</th>
+ <th>Log4j Level</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#OFF
">OFF</a></td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
+ <td>OFF</td>
+ </tr>
+ <tr>
+ <td class="muted">n/a</td>
+ <td>1000 &lt; <var>level</var> &lt; <a class="javadoc"
href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MAX_VALUE
">Integer.MAX_VALUE</a></td>
+ <td>FATAL</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#SEVERE
">SEVERE</a></td>
+ <td>900 &lt; <var>level</var> &le; 1000</td>
+ <td>ERROR</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#WARNING
">WARNING</a></td>
+ <td>800 &lt; <var>level</var> &le; 900</td>
+ <td>WARN</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#INFO
">INFO</a></td>
+ <td>700 &lt; <var>level</var> &le; 800</td>
+ <td>INFO</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#CONFIG
">CONFIG</a></td>
+ <td>500 &lt; <var>level</var> &le; 700</td>
+ <td>INFO</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINE
">FINE</a></td>
+ <td>400 &lt; <var>level</var> &le; 500</td>
+ <td>DEBUG</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINER
">FINER</a></td>
+ <td>300 &lt; <var>level</var> &le; 400</td>
+ <td>DEBUG</td>
+ </tr>
+ <tr>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html#FINEST
">FINEST</a></td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE">Integer.MIN_VALUE</a>
&lt; <var>level</var> &le; 300</td>
+ <td>TRACE</td>
+ </tr>
+ <tr>
+ <td>ALL</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#MIN_VALUE
">Integer.MIN_VALUE</a></td>
+ <td>ALL</td>
+ </tr>
+ </tbody>
+ </table>
+ <p>
+ There are currently three additional pieces of information
obtained from each
+ <a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html
">LogRecord</a>
+ that are stored in the <a
href="../manual/thread-context.html">ThreadContext</a>.
+ </p>
+ <table>
+ <caption>ThreadContext map keys</caption>
+ <thead>
+ <tr>
+ <th>Key</th>
+ <th><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html">LogRecord</a>
Property</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>log4j.jul.threadID</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getThreadID%28%29
">threadID</a></td>
+ <td>An identifier for the thread where the message
originated.</td>
+ </tr>
+ <tr>
+ <td>log4j.jul.sequenceNumber</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getSequenceNumber%28%29
">sequenceNumber</a></td>
+ <td>A unique, increasing sequence number generated by the
LogRecord constructor.</td>
+ </tr>
+ <tr>
+ <td>log4j.jul.level</td>
+ <td><a class="javadoc" href="
http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html#getLevel%28%29
">level</a></td>
+ <td>The logging message level name. This level is
translated into an equivalent Log4j level, so the original
+ logging level name is saved here.</td>
+ </tr>
+ </tbody>
+ </table>
+ </section>
+ </body>
+</document>
\ No newline at end of file
---------------------------------------------------------------------
--
--
Matt Sicker <***@gmail.com>
Loading...