You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/08 00:38:56 UTC
[17/32] git commit: Rename ExternalLoggerContextRegistry to
LoggerAdapter.
Rename ExternalLoggerContextRegistry to LoggerAdapter.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f91c1181
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f91c1181
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f91c1181
Branch: refs/heads/master
Commit: f91c118165b4893c1526267516a96a889d7ec736
Parents: 923ffa3
Author: Matt Sicker <ma...@apache.org>
Authored: Tue Sep 2 01:07:38 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Tue Sep 2 01:07:38 2014 -0500
----------------------------------------------------------------------
.../AbstractExternalLoggerContextRegistry.java | 63 --------------------
.../log4j/spi/AbstractLoggerAdapter.java | 63 ++++++++++++++++++++
.../spi/ExternalLoggerContextRegistry.java | 52 ----------------
.../apache/logging/log4j/spi/LoggerAdapter.java | 52 ++++++++++++++++
.../apache/logging/log4j/jcl/LogAdapter.java | 56 +++++++++++++++++
.../logging/log4j/jcl/LogFactoryImpl.java | 8 +--
.../apache/logging/log4j/jcl/LogRegistry.java | 56 -----------------
.../log4j/jdk/AbstractLoggerAdapter.java | 44 ++++++++++++++
.../log4j/jdk/AbstractLoggerRegistry.java | 45 --------------
.../logging/log4j/jdk/ApiLoggerAdapter.java | 34 +++++++++++
.../logging/log4j/jdk/ApiLoggerRegistry.java | 34 -----------
.../logging/log4j/jdk/CoreLoggerAdapter.java | 35 +++++++++++
.../logging/log4j/jdk/CoreLoggerRegistry.java | 35 -----------
.../apache/logging/log4j/jdk/LogManager.java | 11 ++--
.../logging/slf4j/Log4jLoggerFactory.java | 4 +-
15 files changed, 295 insertions(+), 297 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractExternalLoggerContextRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractExternalLoggerContextRegistry.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractExternalLoggerContextRegistry.java
deleted file mode 100644
index 9e7a8fc..0000000
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractExternalLoggerContextRegistry.java
+++ /dev/null
@@ -1,63 +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.spi;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Provides an abstract base class to use for implementing ExternalLoggerContextRegistry.
- * @since 2.1
- */
-public abstract class AbstractExternalLoggerContextRegistry<L> implements ExternalLoggerContextRegistry<L> {
-
- /**
- * A map to store loggers for their given LoggerContexts.
- */
- protected final Map<LoggerContext, ConcurrentMap<String, L>> registry =
- new WeakHashMap<LoggerContext, ConcurrentMap<String, L>>();
-
- @Override
- public L getLogger(String name) {
- final LoggerContext context = getContext();
- final ConcurrentMap<String, L> loggers = getLoggersInContext(context);
- if (loggers.containsKey(name)) {
- return loggers.get(name);
- }
- loggers.putIfAbsent(name, newLogger(name, context));
- return loggers.get(name);
- }
-
- @Override
- public ConcurrentMap<String, L> getLoggersInContext(final LoggerContext context) {
- synchronized (registry) {
- ConcurrentMap<String, L> loggers = registry.get(context);
- if (loggers == null) {
- loggers = new ConcurrentHashMap<String, L>();
- registry.put(context, loggers);
- }
- return loggers;
- }
- }
-
- @Override
- public void stop() {
- registry.clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerAdapter.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerAdapter.java
new file mode 100644
index 0000000..56fa730
--- /dev/null
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerAdapter.java
@@ -0,0 +1,63 @@
+/*
+ * 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.spi;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Provides an abstract base class to use for implementing ExternalLoggerContextRegistry.
+ * @since 2.1
+ */
+public abstract class AbstractLoggerAdapter<L> implements LoggerAdapter<L> {
+
+ /**
+ * A map to store loggers for their given LoggerContexts.
+ */
+ protected final Map<LoggerContext, ConcurrentMap<String, L>> registry =
+ new WeakHashMap<LoggerContext, ConcurrentMap<String, L>>();
+
+ @Override
+ public L getLogger(String name) {
+ final LoggerContext context = getContext();
+ final ConcurrentMap<String, L> loggers = getLoggersInContext(context);
+ if (loggers.containsKey(name)) {
+ return loggers.get(name);
+ }
+ loggers.putIfAbsent(name, newLogger(name, context));
+ return loggers.get(name);
+ }
+
+ @Override
+ public ConcurrentMap<String, L> getLoggersInContext(final LoggerContext context) {
+ synchronized (registry) {
+ ConcurrentMap<String, L> loggers = registry.get(context);
+ if (loggers == null) {
+ loggers = new ConcurrentHashMap<String, L>();
+ registry.put(context, loggers);
+ }
+ return loggers;
+ }
+ }
+
+ @Override
+ public void stop() {
+ registry.clear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExternalLoggerContextRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExternalLoggerContextRegistry.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExternalLoggerContextRegistry.java
deleted file mode 100644
index 25d3096..0000000
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExternalLoggerContextRegistry.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.logging.log4j.spi;
-
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * A basic registry for {@link LoggerContext} objects and their associated external
- * Logger classes. This registry should not be used for Log4j Loggers; it is instead used for creating bridges to
- * other external log systems.
- *
- * @param <L> the external logger class for this registry (e.g., {@code org.slf4j.Logger})
- * @since 2.1
- */
-public interface ExternalLoggerContextRegistry<L> {
-
- /**
- * Gets a named logger linked to the {@link LoggerContext} returned by {@link #getContext()}. If no logger of
- * the given name exists, then a new logger will be created using {@link #newLogger(String, LoggerContext)}.
- *
- * @param name the name of the logger to get
- * @return the named logger
- */
- L getLogger(String name);
-
- /**
- * Creates a new named logger for a given {@link LoggerContext}.
- *
- * @param name the name of the logger to create
- * @param context the LoggerContext this logger will be associated with
- * @return the new named logger
- */
- L newLogger(String name, LoggerContext context);
-
- /**
- * Gets the {@link LoggerContext} that should be used to look up or create loggers.
- *
- * @return the LoggerContext to be used for lookup and creation purposes
- */
- LoggerContext getContext();
-
- /**
- * Gets or creates the ConcurrentMap of named loggers for a given LoggerContext.
- *
- * @param context the LoggerContext to get loggers for
- * @return the map of loggers for the given LoggerContext
- */
- ConcurrentMap<String, L> getLoggersInContext(LoggerContext context);
-
- /**
- * Shuts down this registry. Implementations should clear out any instance data and perform any relevant clean-up.
- */
- void stop();
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerAdapter.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerAdapter.java
new file mode 100644
index 0000000..84d441c
--- /dev/null
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggerAdapter.java
@@ -0,0 +1,52 @@
+package org.apache.logging.log4j.spi;
+
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * A basic registry for {@link LoggerContext} objects and their associated external
+ * Logger classes. This registry should not be used for Log4j Loggers; it is instead used for creating bridges to
+ * other external log systems.
+ *
+ * @param <L> the external logger class for this registry (e.g., {@code org.slf4j.Logger})
+ * @since 2.1
+ */
+public interface LoggerAdapter<L> {
+
+ /**
+ * Gets a named logger linked to the {@link LoggerContext} returned by {@link #getContext()}. If no logger of
+ * the given name exists, then a new logger will be created using {@link #newLogger(String, LoggerContext)}.
+ *
+ * @param name the name of the logger to get
+ * @return the named logger
+ */
+ L getLogger(String name);
+
+ /**
+ * Creates a new named logger for a given {@link LoggerContext}.
+ *
+ * @param name the name of the logger to create
+ * @param context the LoggerContext this logger will be associated with
+ * @return the new named logger
+ */
+ L newLogger(String name, LoggerContext context);
+
+ /**
+ * Gets the {@link LoggerContext} that should be used to look up or create loggers.
+ *
+ * @return the LoggerContext to be used for lookup and creation purposes
+ */
+ LoggerContext getContext();
+
+ /**
+ * Gets or creates the ConcurrentMap of named loggers for a given LoggerContext.
+ *
+ * @param context the LoggerContext to get loggers for
+ * @return the map of loggers for the given LoggerContext
+ */
+ ConcurrentMap<String, L> getLoggersInContext(LoggerContext context);
+
+ /**
+ * Shuts down this registry. Implementations should clear out any instance data and perform any relevant clean-up.
+ */
+ void stop();
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogAdapter.java b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogAdapter.java
new file mode 100644
index 0000000..b1e1e2b
--- /dev/null
+++ b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogAdapter.java
@@ -0,0 +1,56 @@
+/*
+ * 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.jcl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+import org.apache.logging.log4j.spi.LoggerContext;
+
+/**
+ * Commons Logging registry.
+ */
+public class LogAdapter extends AbstractLoggerAdapter<Log> {
+
+ @Override
+ public Log newLogger(final String name, final LoggerContext context) {
+ return new Log4jLog(PrivateManager.getLogger(name));
+ }
+
+ @Override
+ public LoggerContext getContext() {
+ return PrivateManager.getContext();
+ }
+
+ /**
+ * The real bridge between commons logging and Log4j.
+ */
+ private static class PrivateManager extends LogManager {
+ private static final String FQCN = LogFactory.class.getName();
+
+ public static LoggerContext getContext() {
+ return getContext(FQCN, false);
+ }
+
+ public static ExtendedLogger getLogger(final String name) {
+ return getContext().getLogger(name);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
----------------------------------------------------------------------
diff --git a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
index bcb19b0..2c0bb6d 100644
--- a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
+++ b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
@@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.spi.ExternalLoggerContextRegistry;
+import org.apache.logging.log4j.spi.LoggerAdapter;
/**
* Log4j binding for Commons Logging.
@@ -30,13 +30,13 @@ import org.apache.logging.log4j.spi.ExternalLoggerContextRegistry;
*/
public class LogFactoryImpl extends LogFactory {
- private final ExternalLoggerContextRegistry<Log> registry = new LogRegistry();
+ private final LoggerAdapter<Log> adapter = new LogAdapter();
private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
@Override
public Log getInstance(final String name) throws LogConfigurationException {
- return registry.getLogger(name);
+ return adapter.getLogger(name);
}
@Override
@@ -60,7 +60,7 @@ public class LogFactoryImpl extends LogFactory {
*/
@Override
public void release() {
- registry.stop();
+ adapter.stop();
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogRegistry.java b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogRegistry.java
deleted file mode 100644
index af44c8b..0000000
--- a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/LogRegistry.java
+++ /dev/null
@@ -1,56 +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.jcl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.AbstractExternalLoggerContextRegistry;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * Commons Logging registry.
- */
-public class LogRegistry extends AbstractExternalLoggerContextRegistry<Log> {
-
- @Override
- public Log newLogger(final String name, final LoggerContext context) {
- return new Log4jLog(PrivateManager.getLogger(name));
- }
-
- @Override
- public LoggerContext getContext() {
- return PrivateManager.getContext();
- }
-
- /**
- * The real bridge between commons logging and Log4j.
- */
- private static class PrivateManager extends LogManager {
- private static final String FQCN = LogFactory.class.getName();
-
- public static LoggerContext getContext() {
- return getContext(FQCN, false);
- }
-
- public static ExtendedLogger getLogger(final String name) {
- return getContext().getLogger(name);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerAdapter.java
new file mode 100644
index 0000000..29f0aa0
--- /dev/null
+++ b/log4j-jdk/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
+ * to create: {@link ApiLoggerAdapter} and {@link CoreLoggerAdapter}.
+ *
+ * @since 2.1
+ */
+public abstract class AbstractLoggerAdapter extends org.apache.logging.log4j.spi.AbstractLoggerAdapter<Logger> {
+
+ @Override
+ 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/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerRegistry.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerRegistry.java
deleted file mode 100644
index e1b9394..0000000
--- a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/AbstractLoggerRegistry.java
+++ /dev/null
@@ -1,45 +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.AbstractExternalLoggerContextRegistry;
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * Abstract Logger registry. Due to the optionality of using log4j-core, there are two registries available at runtime
- * to create: {@link ApiLoggerRegistry} and {@link CoreLoggerRegistry}.
- *
- * @since 2.1
- */
-public abstract class AbstractLoggerRegistry extends AbstractExternalLoggerContextRegistry<Logger> {
-
- @Override
- 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/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerAdapter.java
new file mode 100644
index 0000000..6b3cd65
--- /dev/null
+++ b/log4j-jdk/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;
+
+/**
+ * {@link Logger} registry implementation using just log4j-api. This is the fallback registry used when log4j-core is
+ * not available.
+ *
+ * @since 2.1
+ */
+public class ApiLoggerAdapter extends AbstractLoggerAdapter {
+ @Override
+ 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/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerRegistry.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerRegistry.java
deleted file mode 100644
index bd259a0..0000000
--- a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/ApiLoggerRegistry.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.jdk;
-
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * {@link Logger} registry implementation using just log4j-api. This is the fallback registry used when log4j-core is
- * not available.
- *
- * @since 2.1
- */
-public class ApiLoggerRegistry extends AbstractLoggerRegistry {
- @Override
- public Logger newLogger(final String name, final LoggerContext context) {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerAdapter.java
new file mode 100644
index 0000000..d91eae1
--- /dev/null
+++ b/log4j-jdk/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;
+
+/**
+ * {@link Logger} registry implementation that uses log4j-core.
+ *
+ * @since 2.1
+ */
+public class CoreLoggerAdapter extends AbstractLoggerAdapter {
+
+ @Override
+ 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/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerRegistry.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerRegistry.java
deleted file mode 100644
index 8c842b2..0000000
--- a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/CoreLoggerRegistry.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.jdk;
-
-import java.util.logging.Logger;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * {@link Logger} registry implementation that uses log4j-core.
- *
- * @since 2.1
- */
-public class CoreLoggerRegistry extends AbstractLoggerRegistry {
-
- @Override
- 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/f91c1181/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
----------------------------------------------------------------------
diff --git a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
index b6f6e3e..8d2ae43 100644
--- a/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
+++ b/log4j-jdk/src/main/java/org/apache/logging/log4j/jdk/LogManager.java
@@ -20,7 +20,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.logging.Logger;
-import org.apache.logging.log4j.spi.ExternalLoggerContextRegistry;
+import org.apache.logging.log4j.spi.LoggerAdapter;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.LoaderUtil;
@@ -35,6 +35,7 @@ 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
@@ -47,14 +48,12 @@ public class LogManager extends java.util.logging.LogManager {
}
LOGGER.debug("Attempting to use {}", registryClassName);
try {
- REGISTRY = LoaderUtil.newCheckedInstanceOf(registryClassName, AbstractLoggerRegistry.class);
+ ADAPTER = LoaderUtil.newCheckedInstanceOf(registryClassName, AbstractLoggerAdapter.class);
} catch (final Exception e) {
throw LOGGER.throwing(new ExceptionInInitializerError(e));
}
}
- private static final ExternalLoggerContextRegistry<Logger> REGISTRY;
-
public LogManager() {
super();
LOGGER.info("Registered Log4j as the java.util.logging.LogManager.");
@@ -70,12 +69,12 @@ public class LogManager extends java.util.logging.LogManager {
@Override
public Logger getLogger(final String name) {
LOGGER.trace("Call to LogManager.getLogger({})", name);
- return REGISTRY.getLogger(name);
+ return ADAPTER.getLogger(name);
}
@Override
public Enumeration<String> getLoggerNames() {
- return Collections.enumeration(REGISTRY.getLoggersInContext(REGISTRY.getContext()).keySet());
+ return Collections.enumeration(ADAPTER.getLoggersInContext(ADAPTER.getContext()).keySet());
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f91c1181/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
index 2878618..5fd50bd 100644
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
+++ b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
@@ -17,7 +17,7 @@
package org.apache.logging.slf4j;
import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.AbstractExternalLoggerContextRegistry;
+import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
import org.apache.logging.log4j.spi.ExtendedLogger;
import org.apache.logging.log4j.spi.LoggerContext;
import org.slf4j.ILoggerFactory;
@@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
-public class Log4jLoggerFactory extends AbstractExternalLoggerContextRegistry<Logger> implements ILoggerFactory {
+public class Log4jLoggerFactory extends AbstractLoggerAdapter<Logger> implements ILoggerFactory {
private static final String FQCN = Log4jLoggerFactory.class.getName();
private static final String PACKAGE = "org.slf4j";