diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java index bec6b9502f2b9..8475c902cd8e8 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java @@ -19,7 +19,6 @@ package org.elasticsearch.analysis.common; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.CharArraySet; import org.apache.lucene.analysis.StopFilter; @@ -157,7 +156,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, ScriptPlugin { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(CommonAnalysisPlugin.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(CommonAnalysisPlugin.class); private final SetOnce scriptService = new SetOnce<>(); diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java index 721fe7bf91757..62189a1d7f34a 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java @@ -19,7 +19,6 @@ package org.elasticsearch.analysis.common; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.synonym.SynonymFilter; @@ -43,8 +42,7 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory { - private static final DeprecationLogger DEPRECATION_LOGGER - = new DeprecationLogger(LogManager.getLogger(SynonymTokenFilterFactory.class)); + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(SynonymTokenFilterFactory.class); private final String format; private final boolean expand; diff --git a/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java b/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java index 4523b5aff69bb..4d2bc2273eabe 100644 --- a/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java +++ b/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java @@ -19,7 +19,6 @@ package org.elasticsearch.ingest.useragent; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.ingest.AbstractProcessor; import org.elasticsearch.ingest.IngestDocument; @@ -41,7 +40,7 @@ public class UserAgentProcessor extends AbstractProcessor { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(UserAgentProcessor.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(UserAgentProcessor.class); public static final String TYPE = "user_agent"; diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java index a3d39ad7e0b6d..521cc26883484 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java @@ -19,8 +19,6 @@ package org.elasticsearch.index.reindex; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.lucene.util.automaton.Automata; import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.CharacterRunAutomaton; @@ -42,8 +40,7 @@ import java.util.List; class ReindexValidator { - private static final Logger logger = LogManager.getLogger(ReindexValidator.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ReindexValidator.class); static final String SORT_DEPRECATED_MESSAGE = "The sort option in reindex is deprecated. " + "Instead consider using query filtering to find the desired subset of data."; diff --git a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java index d4d59a52e19bc..c2a614d52e747 100644 --- a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java +++ b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java @@ -44,7 +44,7 @@ public class AzureDiscoveryPlugin extends Plugin implements DiscoveryPlugin { public static final String AZURE = "azure"; protected final Settings settings; private static final Logger logger = LogManager.getLogger(AzureDiscoveryPlugin.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(AzureDiscoveryPlugin.class); public AzureDiscoveryPlugin(Settings settings) { this.settings = settings; diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java index 9127e5040a433..8e97d4ba7455c 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java @@ -77,7 +77,7 @@ final class Ec2ClientSettings { private static final Logger logger = LogManager.getLogger(Ec2ClientSettings.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Ec2ClientSettings.class); /** Credentials to authenticate with ec2. */ final AWSCredentials credentials; diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java index fd21f6ad03f93..fdd64ef1e73d1 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java @@ -108,7 +108,7 @@ public void testLocationInfoTest() throws IOException, UserException { public void testConcurrentDeprecationLogger() throws IOException, UserException, BrokenBarrierException, InterruptedException { setupLogging("deprecation"); - final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger("deprecation")); + final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("deprecation"); final int numberOfThreads = randomIntBetween(2, 4); final CyclicBarrier barrier = new CyclicBarrier(1 + numberOfThreads); @@ -194,7 +194,7 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException, public void testDeprecationLoggerMaybeLog() throws IOException, UserException { setupLogging("deprecation"); - final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger("deprecation")); + final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("deprecation"); final int iterations = randomIntBetween(1, 16); diff --git a/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java b/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java index 9461c9026fbeb..c2a467212c084 100644 --- a/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java +++ b/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java @@ -336,7 +336,7 @@ public void testJsonInStacktraceMessageIsNotSplitted() throws IOException { public void testDuplicateLogMessages() throws IOException { - final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger("test")); + final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("test"); // For the same key and X-Opaque-ID deprecation should be once ThreadContext threadContext = new ThreadContext(Settings.EMPTY); diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecatedQueryBuilder.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecatedQueryBuilder.java index 1d2555eb0e636..9286782321e2e 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecatedQueryBuilder.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecatedQueryBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.http; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.Query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; @@ -41,8 +40,7 @@ public class TestDeprecatedQueryBuilder extends AbstractQueryBuilder { public static final String NAME = "deprecated_match_all"; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(TestDeprecatedQueryBuilder.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TestDeprecatedQueryBuilder.class); public TestDeprecatedQueryBuilder() { // nothing to do diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java index f7cf5481590db..eb2331ebef638 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.http; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; @@ -46,8 +44,7 @@ * and returns their values. */ public class TestDeprecationHeaderRestAction extends BaseRestHandler { - private static final Logger logger = LogManager.getLogger(TestDeprecationHeaderRestAction.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TestDeprecationHeaderRestAction.class); public static final Setting TEST_DEPRECATED_SETTING_TRUE1 = Setting.boolSetting("test.setting.deprecated.true1", true, diff --git a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java index aade57a850511..414d8835f4faa 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java @@ -19,14 +19,11 @@ package org.elasticsearch.action.ingest; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; @@ -45,10 +42,6 @@ import java.util.Objects; public class SimulatePipelineRequest extends ActionRequest implements ToXContentObject { - - private static final Logger logger = LogManager.getLogger(SimulatePipelineRequest.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); - private String id; private boolean verbose; private BytesReference source; diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java index 69aa23e5ef8bf..fd1f61a6448b1 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java @@ -112,7 +112,7 @@ */ public class MetadataCreateIndexService { private static final Logger logger = LogManager.getLogger(MetadataCreateIndexService.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(MetadataCreateIndexService.class); public static final int MAX_INDEX_NAME_BYTES = 255; diff --git a/server/src/main/java/org/elasticsearch/common/joda/Joda.java b/server/src/main/java/org/elasticsearch/common/joda/Joda.java index 4eda6fe333a60..07e19ab835d27 100644 --- a/server/src/main/java/org/elasticsearch/common/joda/Joda.java +++ b/server/src/main/java/org/elasticsearch/common/joda/Joda.java @@ -19,7 +19,6 @@ package org.elasticsearch.common.joda; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; @@ -50,8 +49,7 @@ import java.util.regex.Pattern; public class Joda { - - private static DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(Joda.class)); + private static DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Joda.class); /** * Parses a joda based pattern, including some named ones (similar to the built in Joda ISO ones). diff --git a/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java b/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java index b7716a9b91a8d..3a5abf622b0cf 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java +++ b/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java @@ -45,12 +45,19 @@ public class DeprecationLogger { * it replaces "org.elasticsearch" with "org.elasticsearch.deprecation" to maintain * the "org.elasticsearch" namespace. */ - public DeprecationLogger(Logger parentLogger) { - deprecationLogger = new ThrottlingAndHeaderWarningLogger(deprecatedLoggerName(parentLogger)); + private DeprecationLogger(Logger parentLogger) { + deprecationLogger = new ThrottlingAndHeaderWarningLogger(parentLogger); } - private static Logger deprecatedLoggerName(Logger parentLogger) { - String name = parentLogger.getName(); + public static DeprecationLogger getLogger(Class aClass) { + return getLogger(toLoggerName(aClass)); + } + + public static DeprecationLogger getLogger(String name) { + return new DeprecationLogger(deprecatedLoggerName(name)); + } + + private static Logger deprecatedLoggerName(String name) { if (name.startsWith("org.elasticsearch")) { name = name.replace("org.elasticsearch.", "org.elasticsearch.deprecation."); } else { @@ -59,6 +66,11 @@ private static Logger deprecatedLoggerName(Logger parentLogger) { return LogManager.getLogger(name); } + private static String toLoggerName(final Class cls) { + String canonicalName = cls.getCanonicalName(); + return canonicalName != null ? canonicalName : cls.getName(); + } + public static void setThreadContext(ThreadContext threadContext) { HeaderWarning.setThreadContext(threadContext); } diff --git a/server/src/main/java/org/elasticsearch/common/settings/Settings.java b/server/src/main/java/org/elasticsearch/common/settings/Settings.java index 1a7b3ddbafa00..50d4fb994c8b9 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -20,7 +20,6 @@ package org.elasticsearch.common.settings; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.util.SetOnce; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.Version; @@ -319,7 +318,7 @@ public boolean hasValue(String key) { * {@link Setting} object constructed in, for example, {@link org.elasticsearch.env.Environment}. */ static class DeprecationLoggerHolder { - static DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(Settings.class)); + static DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Settings.class); } /** diff --git a/server/src/main/java/org/elasticsearch/common/time/DateUtils.java b/server/src/main/java/org/elasticsearch/common/time/DateUtils.java index bb4b99dd5cf4d..2d742838e95a0 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateUtils.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateUtils.java @@ -19,7 +19,6 @@ package org.elasticsearch.common.time; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.logging.DeprecationLogger; import org.joda.time.DateTimeZone; @@ -52,7 +51,7 @@ public static DateTimeZone zoneIdToDateTimeZone(ZoneId zoneId) { return DateTimeZone.forID(zoneId.getId()); } - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(DateFormatters.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DateUtils.class); // pkg private for tests static final Map DEPRECATED_SHORT_TIMEZONES; public static final Set DEPRECATED_SHORT_TZ_IDS; diff --git a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java index f565b2372784b..e2290173cc31b 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java @@ -19,7 +19,6 @@ package org.elasticsearch.common.unit; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -42,7 +41,7 @@ public class ByteSizeValue implements Writeable, Comparable, ToXC * {@link ByteSizeValue} object constructed in, for example, settings in {@link org.elasticsearch.common.network.NetworkService}. */ static class DeprecationLoggerHolder { - static DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ByteSizeValue.class)); + static DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ByteSizeValue.class); } public static final ByteSizeValue ZERO = new ByteSizeValue(0, ByteSizeUnit.BYTES); diff --git a/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java b/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java index 1aa1397a0b0dd..c4d66e27da05a 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java @@ -19,7 +19,6 @@ package org.elasticsearch.common.xcontent; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.logging.DeprecationLogger; @@ -44,7 +43,7 @@ public class LoggingDeprecationHandler implements DeprecationHandler { * Changing that will require some research to make super duper * sure it is safe. */ - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ParseField.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ParseField.class); private LoggingDeprecationHandler() { // Singleton diff --git a/server/src/main/java/org/elasticsearch/index/AbstractIndexComponent.java b/server/src/main/java/org/elasticsearch/index/AbstractIndexComponent.java index 7760e1041402b..a13a1c689e3f9 100644 --- a/server/src/main/java/org/elasticsearch/index/AbstractIndexComponent.java +++ b/server/src/main/java/org/elasticsearch/index/AbstractIndexComponent.java @@ -34,7 +34,7 @@ public abstract class AbstractIndexComponent implements IndexComponent { */ protected AbstractIndexComponent(IndexSettings indexSettings) { this.logger = Loggers.getLogger(getClass(), indexSettings.getIndex()); - this.deprecationLogger = new DeprecationLogger(logger); + this.deprecationLogger = DeprecationLogger.getLogger(getClass()); this.indexSettings = indexSettings; } diff --git a/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java b/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java index 8d7111a271de7..9e5b13843949a 100644 --- a/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java +++ b/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.analysis; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute; import org.apache.lucene.analysis.shingle.ShingleFilter; @@ -31,8 +30,7 @@ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory { - private static final DeprecationLogger DEPRECATION_LOGGER = - new DeprecationLogger(LogManager.getLogger(ShingleTokenFilterFactory.class)); + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(ShingleTokenFilterFactory.class); private final Factory factory; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java index da8eef96bba34..ecb2f28f9fdf2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.codecs.PostingsFormat; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; @@ -349,7 +348,7 @@ public static class Builder extends FieldMapper.Builder { private boolean preserveSeparators = Defaults.DEFAULT_PRESERVE_SEPARATORS; private boolean preservePositionIncrements = Defaults.DEFAULT_POSITION_INCREMENTS; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(Builder.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Builder.class); /** * @param name of the completion field to build diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java index dafdb29775280..c495ee4ac7cf2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.search.Query; @@ -44,7 +43,7 @@ */ public class FieldNamesFieldMapper extends MetadataFieldMapper { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(FieldNamesFieldMapper.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(FieldNamesFieldMapper.class); public static final String NAME = "_field_names"; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java index ee0f1a263c8ec..3583200dc06b3 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.document.Field; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; @@ -65,7 +64,7 @@ * queries. */ public class IdFieldMapper extends MetadataFieldMapper { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(IdFieldMapper.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(IdFieldMapper.class); static final String ID_FIELD_DATA_DEPRECATION_MESSAGE = "Loading the fielddata on the _id field is deprecated and will be removed in future versions. " + "If you require sorting or aggregating on this field you should also include the id in the " diff --git a/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java index 67a51e0f55785..60c93e1ce300c 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexableField; import org.apache.lucene.spatial.prefix.PrefixTreeStrategy; @@ -178,8 +176,7 @@ private static void checkPrefixTreeSupport(String fieldName) { } } - private static final Logger logger = LogManager.getLogger(LegacyGeoShapeFieldMapper.class); - private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(logger); + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(LegacyGeoShapeFieldMapper.class); public static class Builder extends AbstractShapeGeometryFieldMapper.Builder { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java index aa25ebfb49047..c1f3cf1d64a1a 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.Query; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.Version; @@ -43,7 +42,7 @@ import java.util.Map; public class ObjectMapper extends Mapper implements Cloneable { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ObjectMapper.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ObjectMapper.class); public static final String CONTENT_TYPE = "object"; public static final String NESTED_CONTENT_TYPE = "nested"; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java index be6cb43b8a20f..f23b885082be1 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java @@ -19,8 +19,6 @@ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.elasticsearch.Version; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.Nullable; @@ -45,9 +43,7 @@ import static org.elasticsearch.index.mapper.TypeParsers.parseDateTimeFormatter; public class RootObjectMapper extends ObjectMapper { - - private static final Logger LOGGER = LogManager.getLogger(RootObjectMapper.class); - private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LOGGER); + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(RootObjectMapper.class); public static class Defaults { public static final DateFormatter[] DYNAMIC_DATE_TIME_FORMATTERS = diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java index b2f67ee03d5ac..cfedd83120dea 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.mapper; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.IndexOptions; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.Version; @@ -42,7 +41,7 @@ import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringValue; public class TypeParsers { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(TypeParsers.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TypeParsers.class); public static final String DOC_VALUES = "doc_values"; public static final String INDEX_OPTIONS_DOCS = "docs"; diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java index a9fa9aa6675d0..9b9fe08480e0e 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.Query; import org.elasticsearch.common.ParseField; @@ -30,7 +29,6 @@ import org.elasticsearch.common.geo.parsers.ShapeParser; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.geometry.Geometry; @@ -51,9 +49,6 @@ */ public class GeoShapeQueryBuilder extends AbstractGeometryQueryBuilder { public static final String NAME = "geo_shape"; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(GeoShapeQueryBuilder.class)); - protected static final ParseField STRATEGY_FIELD = new ParseField("strategy"); private SpatialStrategy strategy; diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index 0c85ebd1852b2..095e7f7a327c8 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; @@ -77,8 +76,7 @@ * Context object used to create lucene queries on the shard level. */ public class QueryShardContext extends QueryRewriteContext { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(QueryShardContext.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(QueryShardContext.class); public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using the _type field " + "in queries and aggregations is deprecated, prefer to use a field instead."; diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java index 3f4a2d1993a21..172f0b6d24df1 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.index.query.functionscore; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -38,9 +37,7 @@ * A function that computes a random score for the matched documents */ public class RandomScoreFunctionBuilder extends ScoreFunctionBuilder { - - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RandomScoreFunctionBuilder.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RandomScoreFunctionBuilder.class); public static final String NAME = "random_score"; private String field; diff --git a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java index c786e76c49686..337bae70b8774 100644 --- a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java +++ b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.similarity; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.similarities.AfterEffect; import org.apache.lucene.search.similarities.AfterEffectB; import org.apache.lucene.search.similarities.AfterEffectL; @@ -63,7 +62,7 @@ final class SimilarityProviders { private SimilarityProviders() {} // no instantiation - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(SimilarityProviders.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(SimilarityProviders.class); static final String DISCOUNT_OVERLAPS = "discount_overlaps"; private static final Map BASIC_MODELS = Map.of( diff --git a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java index 84e6b96daf7e4..1c13b60802683 100644 --- a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java +++ b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.similarity; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.FieldInvertState; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.search.CollectionStatistics; @@ -49,8 +48,7 @@ import java.util.function.Supplier; public final class SimilarityService extends AbstractIndexComponent { - - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(SimilarityService.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(SimilarityService.class); public static final String DEFAULT_SIMILARITY = "BM25"; private static final Map>> DEFAULTS; public static final Map> BUILT_IN; diff --git a/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java b/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java index 9ce5b9e5e86cf..1e01474efc61b 100644 --- a/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java +++ b/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java @@ -19,7 +19,6 @@ package org.elasticsearch.indices.analysis; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.analysis.LowerCaseFilter; import org.apache.lucene.analysis.TokenStream; import org.elasticsearch.Version; @@ -71,8 +70,7 @@ public final class AnalysisModule { } private static final IndexSettings NA_INDEX_SETTINGS; - - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(AnalysisModule.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(AnalysisModule.class); private final HunspellService hunspellService; private final AnalysisRegistry analysisRegistry; diff --git a/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java b/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java index c2ad72bfd3e23..3c9500bcde8dd 100644 --- a/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java +++ b/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java @@ -19,7 +19,6 @@ package org.elasticsearch.ingest; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.script.DynamicMap; import org.elasticsearch.script.IngestConditionalScript; @@ -43,8 +42,7 @@ public class ConditionalProcessor extends AbstractProcessor implements WrappingProcessor { - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> FUNCTIONS = Map.of( "_type", value -> { deprecationLogger.deprecate("conditional-processor__type", diff --git a/server/src/main/java/org/elasticsearch/rest/RestController.java b/server/src/main/java/org/elasticsearch/rest/RestController.java index bb015d6632e6b..a88007398a449 100644 --- a/server/src/main/java/org/elasticsearch/rest/RestController.java +++ b/server/src/main/java/org/elasticsearch/rest/RestController.java @@ -62,7 +62,7 @@ public class RestController implements HttpServerTransport.Dispatcher { private static final Logger logger = LogManager.getLogger(RestController.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestController.class); private final PathTrie handlers = new PathTrie<>(RestUtils.REST_DECODER); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java index 642f0e34de666..87d2fc29b245e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSyncedFlushAction.java @@ -45,7 +45,7 @@ public class RestSyncedFlushAction extends BaseRestHandler { private static final Logger logger = LogManager.getLogger(RestSyncedFlushAction.class); - private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(logger); + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(RestSyncedFlushAction.class); @Override public List routes() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java index 1f166e858f80b..bab4e67813132 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeActionDeprecated.java @@ -19,12 +19,10 @@ package org.elasticsearch.rest.action.admin.indices; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -36,10 +34,6 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestUpgradeActionDeprecated extends BaseRestHandler { - - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestUpgradeActionDeprecated.class)); - public static final String UPGRADE_API_DEPRECATION_MESSAGE = "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."; diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java index 8fec4e232060d..e1b6eb86278e3 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestUpgradeStatusActionDeprecated.java @@ -19,12 +19,10 @@ package org.elasticsearch.rest.action.admin.indices; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -38,9 +36,6 @@ public class RestUpgradeStatusActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestUpgradeStatusActionDeprecated.class)); - @Override public List deprecatedRoutes() { return List.of( diff --git a/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java b/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java index 2876ad65f9f7d..4f4f547dd0d2b 100644 --- a/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java +++ b/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; @@ -36,8 +35,7 @@ abstract class AbstractSortScript implements ScorerAware { - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = Map.of( "doc", value -> { deprecationLogger.deprecate("sort-script_doc", diff --git a/server/src/main/java/org/elasticsearch/script/AggregationScript.java b/server/src/main/java/org/elasticsearch/script/AggregationScript.java index 1a38797c2545a..7aefd4fa1dfb5 100644 --- a/server/src/main/java/org/elasticsearch/script/AggregationScript.java +++ b/server/src/main/java/org/elasticsearch/script/AggregationScript.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; @@ -40,8 +39,7 @@ public abstract class AggregationScript implements ScorerAware { public static final ScriptContext CONTEXT = new ScriptContext<>("aggs", Factory.class); - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = Map.of( "doc", value -> { deprecationLogger.deprecate("aggregation-script_doc", diff --git a/server/src/main/java/org/elasticsearch/script/FieldScript.java b/server/src/main/java/org/elasticsearch/script/FieldScript.java index 9d0fb613bedc1..98bbfa32c48d3 100644 --- a/server/src/main/java/org/elasticsearch/script/FieldScript.java +++ b/server/src/main/java/org/elasticsearch/script/FieldScript.java @@ -19,7 +19,6 @@ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.ScriptDocValues; @@ -39,8 +38,7 @@ public abstract class FieldScript { public static final String[] PARAMETERS = {}; - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = Map.of( "doc", value -> { deprecationLogger.deprecate("field-script_doc", diff --git a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java index b44d545c4d444..87d116265a697 100644 --- a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java +++ b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java @@ -19,7 +19,6 @@ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.SuppressLoggerChecks; import org.elasticsearch.common.logging.DeprecationLogger; @@ -62,8 +61,7 @@ public class JodaCompatibleZonedDateTime implements Comparable>, ChronoZonedDateTime, Temporal, TemporalAccessor { private static final DateFormatter DATE_FORMATTER = DateFormatter.forPattern("strict_date_time"); - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(JodaCompatibleZonedDateTime.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(JodaCompatibleZonedDateTime.class); private static void logDeprecated(String key, String message, Object... params) { AccessController.doPrivileged(new PrivilegedAction() { diff --git a/server/src/main/java/org/elasticsearch/script/ScoreScript.java b/server/src/main/java/org/elasticsearch/script/ScoreScript.java index dab2b1208a955..e0c141032ed36 100644 --- a/server/src/main/java/org/elasticsearch/script/ScoreScript.java +++ b/server/src/main/java/org/elasticsearch/script/ScoreScript.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.Scorable; @@ -65,8 +64,7 @@ public Explanation get(double score, Explanation subQueryExplanation) { } } - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = Map.of( "doc", value -> { deprecationLogger.deprecate("score-script_doc", diff --git a/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java b/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java index 640796643e96d..4fbfe35afdf49 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; @@ -51,7 +50,7 @@ public final class ScriptMetadata implements Metadata.Custom, Writeable, ToXCont /** * Standard deprecation logger for used to deprecate allowance of empty templates. */ - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ScriptMetadata.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ScriptMetadata.class); /** * A builder used to modify the currently stored scripts data held within diff --git a/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java b/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java index d238acc12a797..ee92f63c4674b 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java @@ -19,7 +19,6 @@ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; @@ -66,8 +65,7 @@ public interface Factory extends ScriptFactory { public abstract static class MapScript { - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = Map.of( "doc", value -> { deprecationLogger.deprecate("map-script_doc", diff --git a/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java b/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java index d037ff0d69620..a56221e2515f2 100644 --- a/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java +++ b/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java @@ -19,7 +19,6 @@ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.Diff; @@ -59,7 +58,7 @@ public class StoredScriptSource extends AbstractDiffable imp /** * Standard deprecation logger for used to deprecate allowance of empty templates. */ - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(StoredScriptSource.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(StoredScriptSource.class); /** * Standard {@link ParseField} for outer level of stored script source. diff --git a/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java b/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java index 9a104337f9447..444c769cc530e 100644 --- a/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java +++ b/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.script; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.ScriptDocValues; @@ -37,8 +36,7 @@ public abstract class TermsSetQueryScript { public static final ScriptContext CONTEXT = new ScriptContext<>("terms_set", Factory.class); - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DynamicMap.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = Map.of( "doc", value -> { deprecationLogger.deprecate("terms-set-query-script_doc", diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java index 20fd8e5a0edd5..3c7bfc9de7661 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.aggregations.bucket.histogram; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Rounding; @@ -54,8 +53,7 @@ * for the enum and the complicated "state machine" logic */ public class DateIntervalWrapper implements ToXContentFragment, Writeable { - private static final DeprecationLogger DEPRECATION_LOGGER - = new DeprecationLogger(LogManager.getLogger(DateHistogramAggregationBuilder.class)); + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(DateHistogramAggregationBuilder.class); private static final String DEPRECATION_TEXT = "[interval] on [date_histogram] is deprecated, use [fixed_interval] or " + "[calendar_interval] in the future."; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java index 174a4c1fcef98..ee231b2ffd8e4 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.aggregations.bucket.terms; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.query.QueryBuilder; @@ -48,8 +47,7 @@ import java.util.Map; public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFactory { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(SignificantTermsAggregatorFactory.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(SignificantTermsAggregatorFactory.class); static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register(SignificantTermsAggregationBuilder.NAME, diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index fa38704ad4e1b..9bf4abe0b67e2 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.builder; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Nullable; @@ -29,7 +28,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -78,9 +76,6 @@ * @see org.elasticsearch.action.search.SearchRequest#source(SearchSourceBuilder) */ public final class SearchSourceBuilder implements Writeable, ToXContentObject, Rewriteable { - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(SearchSourceBuilder.class)); - public static final ParseField FROM_FIELD = new ParseField("from"); public static final ParseField SIZE_FIELD = new ParseField("size"); public static final ParseField TIMEOUT_FIELD = new ParseField("timeout"); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java index 9bd855fdf1ec0..82106e4de1d0e 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.suggest.completion.context; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.document.LatLonDocValuesField; import org.apache.lucene.document.LatLonPoint; import org.apache.lucene.document.StringField; @@ -75,7 +74,7 @@ public class GeoContextMapping extends ContextMapping { static final String CONTEXT_PRECISION = "precision"; static final String CONTEXT_NEIGHBOURS = "neighbours"; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(GeoContextMapping.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(GeoContextMapping.class); private final int precision; private final String fieldName; diff --git a/server/src/main/java/org/elasticsearch/transport/TransportInfo.java b/server/src/main/java/org/elasticsearch/transport/TransportInfo.java index f4707fc46ad24..8562d69c07b94 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportInfo.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportInfo.java @@ -19,7 +19,6 @@ package org.elasticsearch.transport; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -38,7 +37,7 @@ public class TransportInfo implements ReportingService.Info { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(TransportInfo.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TransportInfo.class); /** Whether to add hostname to publish host field when serializing. */ private static final boolean CNAME_IN_PUBLISH_ADDRESS = diff --git a/server/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java b/server/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java index dfb6f0be9d1f7..54e62bae4710f 100644 --- a/server/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java +++ b/server/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.common.logging; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.simple.SimpleLoggerContext; import org.apache.logging.log4j.simple.SimpleLoggerContextFactory; import org.apache.logging.log4j.spi.ExtendedLogger; @@ -37,11 +36,11 @@ import java.security.ProtectionDomain; import java.util.concurrent.atomic.AtomicBoolean; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.core.Is.is; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class DeprecationLoggerTests extends ESTestCase { @SuppressLoggerChecks(reason = "Safe as this is using mockito") @@ -49,8 +48,6 @@ public void testLogPermissions() { AtomicBoolean supplierCalled = new AtomicBoolean(false); // mocking the logger used inside DeprecationLogger requires heavy hacking... - Logger parentLogger = mock(Logger.class); - when(parentLogger.getName()).thenReturn("logger"); ExtendedLogger mockLogger = mock(ExtendedLogger.class); doAnswer(invocationOnMock -> { supplierCalled.set(true); @@ -73,7 +70,7 @@ public LoggerContext getContext(String fqcn, ClassLoader loader, Object external return context; } }); - DeprecationLogger deprecationLogger = new DeprecationLogger(parentLogger); + DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("logger"); AccessControlContext noPermissionsAcc = new AccessControlContext( new ProtectionDomain[]{new ProtectionDomain(null, new Permissions())} @@ -90,4 +87,19 @@ public LoggerContext getContext(String fqcn, ClassLoader loader, Object external } } + public void testMultipleSlowLoggersUseSingleLog4jLogger() { + org.apache.logging.log4j.core.LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false); + + DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DeprecationLoggerTests.class); + int numberOfLoggersBefore = context.getLoggers().size(); + + class LoggerTest{ + } + DeprecationLogger deprecationLogger2 = DeprecationLogger.getLogger(LoggerTest.class); + + context = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false); + int numberOfLoggersAfter = context.getLoggers().size(); + + assertThat(numberOfLoggersAfter, equalTo(numberOfLoggersBefore+1)); + } } diff --git a/test/logger-usage/src/test/java/org/elasticsearch/test/loggerusage/ESLoggerUsageTests.java b/test/logger-usage/src/test/java/org/elasticsearch/test/loggerusage/ESLoggerUsageTests.java index 1740022f1374b..ad35e8704e09b 100644 --- a/test/logger-usage/src/test/java/org/elasticsearch/test/loggerusage/ESLoggerUsageTests.java +++ b/test/logger-usage/src/test/java/org/elasticsearch/test/loggerusage/ESLoggerUsageTests.java @@ -262,7 +262,7 @@ public void checkFailComplexUsage2(boolean b) { } public void checkDeprecationLogger() { - DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ESLoggerUsageTests.class); deprecationLogger.deprecate("key","message {}", 123); } diff --git a/x-pack/plugin/async-search/qa/rest/src/main/java/org/elasticsearch/query/DeprecatedQueryBuilder.java b/x-pack/plugin/async-search/qa/rest/src/main/java/org/elasticsearch/query/DeprecatedQueryBuilder.java index 7e1f5fdc9e475..0ce331e793d09 100644 --- a/x-pack/plugin/async-search/qa/rest/src/main/java/org/elasticsearch/query/DeprecatedQueryBuilder.java +++ b/x-pack/plugin/async-search/qa/rest/src/main/java/org/elasticsearch/query/DeprecatedQueryBuilder.java @@ -6,7 +6,6 @@ package org.elasticsearch.query; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.elasticsearch.common.ParsingException; @@ -22,7 +21,7 @@ import java.io.IOException; public class DeprecatedQueryBuilder extends AbstractQueryBuilder { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger("Deprecated")); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("Deprecated"); public static final String NAME = "deprecated"; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java index b08f3b97e38eb..104c49e89661f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java @@ -6,7 +6,6 @@ package org.elasticsearch.license; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContent; @@ -29,7 +28,7 @@ public class RestGetLicenseAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGetLicenseAction.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetLicenseAction.class); RestGetLicenseAction() {} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java index edfb48e7de174..e7d26ede0a68c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java @@ -5,8 +5,6 @@ */ package org.elasticsearch.xpack.core; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.lucene.util.SetOnce; import org.elasticsearch.SpecialPermission; import org.elasticsearch.action.ActionRequest; @@ -89,9 +87,7 @@ import java.util.stream.StreamSupport; public class XPackPlugin extends XPackClientPlugin implements ExtensiblePlugin, RepositoryPlugin, EnginePlugin { - - private static final Logger logger = LogManager.getLogger(XPackPlugin.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(XPackPlugin.class); public static final String ASYNC_RESULTS_INDEX = ".async-search"; public static final String XPACK_INSTALLED_NODE_ATTR = "xpack.installed"; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java index a8457092d1f1e..827d4da918217 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.core.transform.action; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionType; import org.elasticsearch.common.ParseField; @@ -33,8 +32,7 @@ public class GetTransformAction extends ActionType public static final GetTransformAction INSTANCE = new GetTransformAction(); public static final String NAME = "cluster:monitor/transform/get"; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(GetTransformAction.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(GetTransformAction.class); private GetTransformAction() { super(NAME, GetTransformAction.Response::new); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java index 5c02cf2808791..427d3e2d16ac7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.core.transform.transforms.pivot; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -36,7 +35,7 @@ public class PivotConfig implements Writeable, ToXContentObject { private static final String NAME = "data_frame_transform_pivot"; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(PivotConfig.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(PivotConfig.class); private final GroupConfig groups; private final AggregationConfig aggregationConfig; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java index 995b5efa22c37..7725512ffe1fd 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.core.transform.transforms; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.logging.DeprecationLogger; @@ -30,8 +29,7 @@ public class MockDeprecatedAggregationBuilder extends ValuesSourceAggregationBui public static final String NAME = "deprecated_agg"; public static final String DEPRECATION_MESSAGE = "expected deprecation message from MockDeprecatedAggregationBuilder"; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(MockDeprecatedAggregationBuilder.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(MockDeprecatedAggregationBuilder.class); protected MockDeprecatedAggregationBuilder(MockDeprecatedAggregationBuilder clone, Builder factoriesBuilder, Map metadata) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java index b03f42ab188a7..896264c9495b8 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.core.transform.transforms; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.Query; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; @@ -29,8 +28,7 @@ public class MockDeprecatedQueryBuilder extends AbstractQueryBuilder PARSER = new ObjectParser<>(NAME, MockDeprecatedQueryBuilder::new); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java index cec8ecb1f6a6a..9ec555d0382f2 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java @@ -86,7 +86,7 @@ public class JobManager { private static final Logger logger = LogManager.getLogger(JobManager.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(JobManager.class); private final JobResultsProvider jobResultsProvider; private final JobResultsPersister jobResultsPersister; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java index 3be46392737a4..02b8a8f8bfbea 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.ml.utils; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.logging.DeprecationLogger; @@ -24,8 +23,7 @@ public final class DomainSplitFunction { - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(DomainSplitFunction.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DomainSplitFunction.class); private static final int MAX_DOMAIN_PART_LENGTH = 63; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java index e2cf21064fa1c..7ffb99518acb8 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java @@ -68,8 +68,7 @@ public class TransportPutRollupJobAction extends TransportMasterNodeAction dailyRoleCache; public DeprecationRoleDescriptorConsumer(ClusterService clusterService, ThreadPool threadPool) { - this(clusterService, threadPool, new DeprecationLogger(logger)); + this(clusterService, threadPool, DeprecationLogger.getLogger(DeprecationRoleDescriptorConsumer.class)); } // package-private for testing diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestDeleteTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestDeleteTransformActionDeprecated.java index 45700b5a20384..e91210aa6871a 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestDeleteTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestDeleteTransformActionDeprecated.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -25,9 +23,6 @@ public class RestDeleteTransformActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestDeleteTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java index cb4061803385d..211e197a4b736 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformActionDeprecated.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -25,10 +23,6 @@ import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MATCH; public class RestGetTransformActionDeprecated extends BaseRestHandler { - - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestGetTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java index 0eae6e7184eb4..5cf0071bc81cc 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestGetTransformStatsActionDeprecated.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -25,10 +23,6 @@ import static org.elasticsearch.xpack.core.transform.TransformField.ALLOW_NO_MATCH; public class RestGetTransformStatsActionDeprecated extends BaseRestHandler { - - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestGetTransformStatsActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPreviewTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPreviewTransformActionDeprecated.java index 5f61a7da46013..195c4b39db5dd 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPreviewTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPreviewTransformActionDeprecated.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -27,9 +25,6 @@ public class RestPreviewTransformActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestPreviewTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPutTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPutTransformActionDeprecated.java index 05353636ba88c..0b99098bc67ee 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPutTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestPutTransformActionDeprecated.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -27,9 +25,6 @@ public class RestPutTransformActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestPutTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStartTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStartTransformActionDeprecated.java index f5436f0c1c04d..63223d0467028 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStartTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStartTransformActionDeprecated.java @@ -6,10 +6,8 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; @@ -26,9 +24,6 @@ public class RestStartTransformActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestStartTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStopTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStopTransformActionDeprecated.java index f15ffcad483c6..72b083aad93a4 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStopTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestStopTransformActionDeprecated.java @@ -5,9 +5,7 @@ */ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -25,9 +23,6 @@ public class RestStopTransformActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestStopTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestUpdateTransformActionDeprecated.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestUpdateTransformActionDeprecated.java index 7a8cc86fe93bc..bfc6773fd155f 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestUpdateTransformActionDeprecated.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/compat/RestUpdateTransformActionDeprecated.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.transform.rest.action.compat; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -27,9 +25,6 @@ public class RestUpdateTransformActionDeprecated extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestUpdateTransformActionDeprecated.class)); - @Override public List routes() { return Collections.emptyList(); diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java index d252ffd92591a..66904e26eafb3 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.vectors.mapper; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.search.DocValuesFieldExistsQuery; @@ -37,7 +36,7 @@ */ @Deprecated public class SparseVectorFieldMapper extends FieldMapper { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(SparseVectorFieldMapper.class)); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(SparseVectorFieldMapper.class); static final String ERROR_MESSAGE = "The [sparse_vector] field type is no longer supported."; static final String ERROR_MESSAGE_7X = "The [sparse_vector] field type is no longer supported. Old 7.x indices are allowed to " + "contain [sparse_vector] fields, but they cannot be indexed or searched."; diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java index 479300cddd179..510ba79fd794f 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java @@ -6,8 +6,6 @@ package org.elasticsearch.xpack.watcher.rest.action; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.DeprecationLogger; @@ -24,8 +22,7 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestWatcherStatsAction extends BaseRestHandler { - private static final Logger logger = LogManager.getLogger(RestWatcherStatsAction.class); - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestWatcherStatsAction.class); @Override public List routes() {