Logging: Drop another deprecated Loggers method (#34520)

Drop a method from `Loggers` that we deprecated because it just
delegated to `LogManager`.
This commit is contained in:
Nik Everett 2018-10-29 10:05:24 -04:00 committed by GitHub
parent cc9894d78a
commit b093116a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 31 deletions

View File

@ -21,8 +21,8 @@ package org.elasticsearch.transport.netty4;
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

View File

@ -76,15 +76,6 @@ public class Loggers {
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}

View File

@ -20,6 +20,7 @@ package org.elasticsearch.cluster.service;
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 class ClusterApplierServiceTests extends ESTestCase {
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 class ClusterApplierServiceTests extends ESTestCase {
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);

View File

@ -20,6 +20,7 @@ package org.elasticsearch.cluster.service;
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 class MasterServiceTests extends ESTestCase {
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 class MasterServiceTests extends ESTestCase {
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);

View File

@ -20,6 +20,7 @@ package org.elasticsearch.common.settings;
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 class SettingsFilterTests extends ESTestCase {
private void assertExpectedLogMessages(Consumer<Logger> 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 {

View File

@ -21,6 +21,7 @@ package org.elasticsearch.index;
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 class MergeSchedulerSettingsTests extends ESTestCase {
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 class MergeSchedulerSettingsTests extends ESTestCase {
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 {

View File

@ -2368,7 +2368,7 @@ public class InternalEngineTests extends EngineTestCase {
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);

View File

@ -80,7 +80,7 @@ public class LoggingListener extends RunListener {
if (loggerName.equalsIgnoreCase("_root")) {
return LogManager.getRootLogger();
}
return Loggers.getLogger(loggerName);
return LogManager.getLogger(loggerName);
}
/**

View File

@ -22,7 +22,6 @@ package org.elasticsearch.test.test;
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 class LoggingListenerTests extends ESTestCase {
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 class LoggingListenerTests extends ESTestCase {
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 class LoggingListenerTests extends ESTestCase {
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();

View File

@ -31,6 +31,7 @@ import joptsimple.OptionSet;
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 class SamlMetadataCommand extends EnvironmentAwareCommand {
@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);