diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4InternalESLogger.java b/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4InternalESLogger.java index 91bbe1c1a9b3c..d4b3aead0d2fd 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4InternalESLogger.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4InternalESLogger.java @@ -21,8 +21,8 @@ import io.netty.util.internal.logging.AbstractInternalLogger; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.SuppressLoggerChecks; -import org.elasticsearch.common.logging.Loggers; @SuppressLoggerChecks(reason = "safely delegates to logger") class Netty4InternalESLogger extends AbstractInternalLogger { @@ -31,7 +31,7 @@ class Netty4InternalESLogger extends AbstractInternalLogger { Netty4InternalESLogger(final String name) { super(name); - this.logger = Loggers.getLogger(name); + this.logger = LogManager.getLogger(name); } @Override diff --git a/server/src/main/java/org/elasticsearch/common/logging/Loggers.java b/server/src/main/java/org/elasticsearch/common/logging/Loggers.java index e5031f4608e8b..28df6206e9bc5 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/Loggers.java +++ b/server/src/main/java/org/elasticsearch/common/logging/Loggers.java @@ -76,15 +76,6 @@ public static Logger getLogger(Logger parentLogger, String s) { return ESLoggerFactory.getLogger(prefix, parentLogger.getName() + s); } - /** - * Get or build a logger. - * @deprecated Prefer {@link LogManager#getLogger} - */ - @Deprecated - public static Logger getLogger(String s) { - return LogManager.getLogger(s); - } - /** * Get or build a logger. * @deprecated Prefer {@link LogManager#getLogger} diff --git a/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java index cf278b80d9e11..989b84f9f1a6b 100644 --- a/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -128,7 +129,7 @@ public void testClusterStateUpdateLogging() throws Exception { Level.TRACE, "*failed to execute cluster state applier in [2s]*")); - Logger clusterLogger = Loggers.getLogger("org.elasticsearch.cluster.service"); + Logger clusterLogger = LogManager.getLogger("org.elasticsearch.cluster.service"); Loggers.addAppender(clusterLogger, mockAppender); try { final CountDownLatch latch = new CountDownLatch(3); @@ -208,7 +209,7 @@ public void testLongClusterStateUpdateLogging() throws Exception { Level.WARN, "*cluster state applier task [test3] took [34s] above the warn threshold of *")); - Logger clusterLogger = Loggers.getLogger("org.elasticsearch.cluster.service"); + Logger clusterLogger = LogManager.getLogger("org.elasticsearch.cluster.service"); Loggers.addAppender(clusterLogger, mockAppender); try { final CountDownLatch latch = new CountDownLatch(4); diff --git a/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java index b95d7b301d8f8..26e36afc551ee 100644 --- a/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; import org.elasticsearch.cluster.AckedClusterStateUpdateTask; @@ -325,7 +326,7 @@ public void testClusterStateUpdateLogging() throws Exception { Level.DEBUG, "*processing [test3]: took [3s] done publishing updated cluster state (version: *, uuid: *)")); - Logger clusterLogger = Loggers.getLogger(masterService.getClass().getPackage().getName()); + Logger clusterLogger = LogManager.getLogger(masterService.getClass().getPackage().getName()); Loggers.addAppender(clusterLogger, mockAppender); try { final CountDownLatch latch = new CountDownLatch(4); @@ -672,7 +673,7 @@ public void testLongClusterStateUpdateLogging() throws Exception { Level.WARN, "*cluster state update task [test4] took [34s] above the warn threshold of *")); - Logger clusterLogger = Loggers.getLogger(masterService.getClass().getPackage().getName()); + Logger clusterLogger = LogManager.getLogger(masterService.getClass().getPackage().getName()); Loggers.addAppender(clusterLogger, mockAppender); try { final CountDownLatch latch = new CountDownLatch(5); diff --git a/server/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java b/server/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java index e6b31d95c85d1..17939f077665d 100644 --- a/server/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java +++ b/server/src/test/java/org/elasticsearch/common/settings/SettingsFilterTests.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Setting.Property; @@ -132,7 +133,7 @@ public void testRegularSettingUpdateIsFullyLogged() throws Exception { private void assertExpectedLogMessages(Consumer consumer, MockLogAppender.LoggingExpectation ... expectations) throws IllegalAccessException { - Logger testLogger = Loggers.getLogger("org.elasticsearch.test"); + Logger testLogger = LogManager.getLogger("org.elasticsearch.test"); MockLogAppender appender = new MockLogAppender(); Loggers.addAppender(testLogger, appender); try { diff --git a/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java b/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java index e9eb5d8b83d2e..c3c2a8176e3eb 100644 --- a/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java @@ -21,6 +21,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.appender.AbstractAppender; import org.apache.logging.log4j.core.filter.RegexFilter; @@ -70,7 +71,7 @@ public boolean ignoreExceptions() { public void testUpdateAutoThrottleSettings() throws Exception { MockAppender mockAppender = new MockAppender("testUpdateAutoThrottleSettings"); mockAppender.start(); - final Logger settingsLogger = Loggers.getLogger("org.elasticsearch.common.settings.IndexScopedSettings"); + final Logger settingsLogger = LogManager.getLogger("org.elasticsearch.common.settings.IndexScopedSettings"); Loggers.addAppender(settingsLogger, mockAppender); Loggers.setLevel(settingsLogger, Level.TRACE); try { @@ -101,7 +102,7 @@ public void testUpdateAutoThrottleSettings() throws Exception { public void testUpdateMergeMaxThreadCount() throws Exception { MockAppender mockAppender = new MockAppender("testUpdateAutoThrottleSettings"); mockAppender.start(); - final Logger settingsLogger = Loggers.getLogger("org.elasticsearch.common.settings.IndexScopedSettings"); + final Logger settingsLogger = LogManager.getLogger("org.elasticsearch.common.settings.IndexScopedSettings"); Loggers.addAppender(settingsLogger, mockAppender); Loggers.setLevel(settingsLogger, Level.TRACE); try { diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index efbce034de47e..deb2f4c549623 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -2368,7 +2368,7 @@ public void testIndexWriterIFDInfoStream() throws IllegalAccessException, IOExce MockAppender mockAppender = new MockAppender("testIndexWriterIFDInfoStream"); mockAppender.start(); - final Logger iwIFDLogger = Loggers.getLogger("org.elasticsearch.index.engine.Engine.IFD"); + final Logger iwIFDLogger = LogManager.getLogger("org.elasticsearch.index.engine.Engine.IFD"); Loggers.addAppender(iwIFDLogger, mockAppender); Loggers.setLevel(iwIFDLogger, Level.DEBUG); diff --git a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/LoggingListener.java b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/LoggingListener.java index eb300ba302b01..5f64bcc21df97 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/LoggingListener.java +++ b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/LoggingListener.java @@ -80,7 +80,7 @@ private static Logger resolveLogger(String loggerName) { if (loggerName.equalsIgnoreCase("_root")) { return LogManager.getRootLogger(); } - return Loggers.getLogger(loggerName); + return LogManager.getLogger(loggerName); } /** diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java index fe5dedb2d5a7e..90c7421108974 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java @@ -22,7 +22,6 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.junit.listeners.LoggingListener; @@ -48,8 +47,8 @@ public void testCustomLevelPerMethod() throws Exception { Description suiteDescription = Description.createSuiteDescription(TestClass.class); - Logger xyzLogger = Loggers.getLogger("xyz"); - Logger abcLogger = Loggers.getLogger("abc"); + Logger xyzLogger = LogManager.getLogger("xyz"); + Logger abcLogger = LogManager.getLogger("abc"); final Level level = LogManager.getRootLogger().getLevel(); @@ -80,13 +79,13 @@ public void testCustomLevelPerClass() throws Exception { Description suiteDescription = Description.createSuiteDescription(AnnotatedTestClass.class); - Logger abcLogger = Loggers.getLogger("abc"); - Logger xyzLogger = Loggers.getLogger("xyz"); + Logger abcLogger = LogManager.getLogger("abc"); + Logger xyzLogger = LogManager.getLogger("xyz"); // we include foo and foo.bar to maintain that logging levels are applied from the top of the hierarchy down; this ensures that // setting the logging level for a parent logger and a child logger applies the parent level first and then the child as otherwise // setting the parent level would overwrite the child level - Logger fooLogger = Loggers.getLogger("foo"); - Logger fooBarLogger = Loggers.getLogger("foo.bar"); + Logger fooLogger = LogManager.getLogger("foo"); + Logger fooBarLogger = LogManager.getLogger("foo.bar"); final Level level = LogManager.getRootLogger().getLevel(); @@ -125,8 +124,8 @@ public void testCustomLevelPerClassAndPerMethod() throws Exception { Description suiteDescription = Description.createSuiteDescription(AnnotatedTestClass.class); - Logger abcLogger = Loggers.getLogger("abc"); - Logger xyzLogger = Loggers.getLogger("xyz"); + Logger abcLogger = LogManager.getLogger("abc"); + Logger xyzLogger = LogManager.getLogger("xyz"); final Level level = LogManager.getRootLogger().getLevel(); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlMetadataCommand.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlMetadataCommand.java index 9aad0272f4801..eacae4621baac 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlMetadataCommand.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlMetadataCommand.java @@ -31,6 +31,7 @@ import joptsimple.OptionSpec; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.cli.EnvironmentAwareCommand; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.SuppressForbidden; @@ -141,9 +142,9 @@ public void close() throws IOException { @Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { // OpenSAML prints a lot of _stuff_ at info level, that really isn't needed in a command line tool. - Loggers.setLevel(Loggers.getLogger("org.opensaml"), Level.WARN); + Loggers.setLevel(LogManager.getLogger("org.opensaml"), Level.WARN); - final Logger logger = Loggers.getLogger(getClass()); + final Logger logger = LogManager.getLogger(getClass()); SamlUtils.initialize(logger); final EntityDescriptor descriptor = buildEntityDescriptor(terminal, options, env);