Skip to content

Commit ffcd5fb

Browse files
committed
Logger: Merge ESLoggerFactory into Loggers (#35146)
`ESLoggerFactory` is now not particularly interesting and simple enought to fold entirely into `Loggers. So let's do that. Closes #32174
1 parent b1ce4b2 commit ffcd5fb

File tree

42 files changed

+128
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+128
-153
lines changed

client/rest-high-level/src/main/resources/forbidden/rest-high-level-signatures.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ org.apache.http.entity.ContentType#create(java.lang.String,org.apache.http.NameV
2222

2323
@defaultMessage ES's logging infrastructure uses log4j2 which we don't want to force on high level rest client users
2424
org.elasticsearch.common.logging.DeprecationLogger
25-
org.elasticsearch.common.logging.ESLoggerFactory
2625
org.elasticsearch.common.logging.LogConfigurator
2726
org.elasticsearch.common.logging.LoggerMessageFormat
2827
org.elasticsearch.common.logging.Loggers

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.analysis.common;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.apache.lucene.analysis.Analyzer;
2324
import org.apache.lucene.analysis.CharArraySet;
2425
import org.apache.lucene.analysis.LowerCaseFilter;
@@ -116,7 +117,6 @@
116117
import org.elasticsearch.cluster.service.ClusterService;
117118
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
118119
import org.elasticsearch.common.logging.DeprecationLogger;
119-
import org.elasticsearch.common.logging.Loggers;
120120
import org.elasticsearch.common.regex.Regex;
121121
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
122122
import org.elasticsearch.env.Environment;
@@ -152,7 +152,7 @@
152152

153153
public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, ScriptPlugin {
154154

155-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(CommonAnalysisPlugin.class));
155+
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(CommonAnalysisPlugin.class));
156156

157157
private final SetOnce<ScriptService> scriptService = new SetOnce<>();
158158

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.percolator;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.apache.lucene.analysis.Analyzer;
2324
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
2425
import org.apache.lucene.index.BinaryDocValues;
@@ -55,7 +56,6 @@
5556
import org.elasticsearch.common.io.stream.StreamInput;
5657
import org.elasticsearch.common.io.stream.StreamOutput;
5758
import org.elasticsearch.common.logging.DeprecationLogger;
58-
import org.elasticsearch.common.logging.Loggers;
5959
import org.elasticsearch.common.lucene.search.Queries;
6060
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
6161
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -98,7 +98,7 @@
9898
public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBuilder> {
9999
public static final String NAME = "percolate";
100100

101-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(ParseField.class));
101+
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(ParseField.class));
102102

103103
static final ParseField DOCUMENT_FIELD = new ParseField("document");
104104
static final ParseField DOCUMENTS_FIELD = new ParseField("documents");

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.percolator;
2020

21+
import org.apache.logging.log4j.LogManager;
2122
import org.apache.lucene.document.BinaryRange;
2223
import org.apache.lucene.document.Field;
2324
import org.apache.lucene.document.NumericDocValuesField;
@@ -51,7 +52,6 @@
5152
import org.elasticsearch.common.hash.MurmurHash3;
5253
import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
5354
import org.elasticsearch.common.logging.DeprecationLogger;
54-
import org.elasticsearch.common.logging.Loggers;
5555
import org.elasticsearch.common.settings.Setting;
5656
import org.elasticsearch.common.settings.Settings;
5757
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -103,7 +103,7 @@ public class PercolatorFieldMapper extends FieldMapper {
103103
static final Setting<Boolean> INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING = Setting.boolSetting(
104104
"index.percolator.map_unmapped_fields_as_text", false, Setting.Property.IndexScope);
105105
static final String CONTENT_TYPE = "percolator";
106-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(PercolatorFieldMapper.class));
106+
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(PercolatorFieldMapper.class));
107107
private static final FieldType FIELD_TYPE = new FieldType();
108108

109109
static final byte FIELD_VALUE_SEPARATOR = 0; // nul code point

modules/tribe/src/main/java/org/elasticsearch/tribe/TribeService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.tribe;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.apache.logging.log4j.message.ParameterizedMessage;
2324
import org.apache.logging.log4j.util.Supplier;
2425
import org.apache.lucene.util.BytesRef;
@@ -49,7 +50,6 @@
4950
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
5051
import org.elasticsearch.common.io.stream.StreamInput;
5152
import org.elasticsearch.common.logging.DeprecationLogger;
52-
import org.elasticsearch.common.logging.Loggers;
5353
import org.elasticsearch.common.network.NetworkModule;
5454
import org.elasticsearch.common.network.NetworkService;
5555
import org.elasticsearch.common.regex.Regex;
@@ -183,7 +183,7 @@ public TribeService(Settings settings, NodeEnvironment nodeEnvironment, ClusterS
183183
this.blockIndicesRead = BLOCKS_READ_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
184184
this.blockIndicesWrite = BLOCKS_WRITE_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
185185
if (!nodes.isEmpty()) {
186-
new DeprecationLogger(Loggers.getLogger(TribeService.class))
186+
new DeprecationLogger(LogManager.getLogger(TribeService.class))
187187
.deprecated("tribe nodes are deprecated in favor of cross-cluster search and will be removed in Elasticsearch 7.0.0");
188188
}
189189
this.onConflict = ON_CONFLICT_SETTING.get(settings);

plugins/discovery-file/src/main/java/org/elasticsearch/discovery/file/FileBasedDiscoveryPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
package org.elasticsearch.discovery.file;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.elasticsearch.common.logging.DeprecationLogger;
23-
import org.elasticsearch.common.logging.Loggers;
2424
import org.elasticsearch.common.network.NetworkService;
2525
import org.elasticsearch.discovery.zen.UnicastHostsProvider;
2626
import org.elasticsearch.plugins.DiscoveryPlugin;
@@ -38,7 +38,7 @@ public class FileBasedDiscoveryPlugin extends Plugin implements DiscoveryPlugin
3838
= "File-based discovery is now built into Elasticsearch and does not require the discovery-file plugin";
3939

4040
public FileBasedDiscoveryPlugin() {
41-
deprecationLogger = new DeprecationLogger(Loggers.getLogger(this.getClass()));
41+
deprecationLogger = new DeprecationLogger(LogManager.getLogger(this.getClass()));
4242
}
4343

4444
@Override

qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.logging.log4j.core.appender.ConsoleAppender;
2828
import org.apache.logging.log4j.core.appender.CountingNoOpAppender;
2929
import org.apache.logging.log4j.core.config.Configurator;
30-
import org.apache.logging.log4j.spi.ExtendedLogger;
3130
import org.apache.logging.log4j.message.ParameterizedMessage;
3231
import org.apache.lucene.util.Constants;
3332
import org.elasticsearch.cli.UserException;
@@ -301,7 +300,7 @@ public void testPrefixLogger() throws IOException, IllegalAccessException, UserE
301300
setupLogging("prefix");
302301

303302
final String prefix = randomAlphaOfLength(16);
304-
final Logger logger = new PrefixLogger((ExtendedLogger) LogManager.getLogger("prefix_test"), "prefix_test", prefix);
303+
final Logger logger = new PrefixLogger(LogManager.getLogger("prefix_test"), prefix);
305304
logger.info("test");
306305
logger.info("{}", "test");
307306
final Exception e = new Exception("exception");
@@ -332,7 +331,7 @@ public void testPrefixLoggerMarkersCanBeCollected() throws IOException, UserExce
332331
final int prefixes = 1 << 19; // to ensure enough markers that the GC should collect some when we force a GC below
333332
for (int i = 0; i < prefixes; i++) {
334333
// this has the side effect of caching a marker with this prefix
335-
new PrefixLogger((ExtendedLogger) LogManager.getLogger("prefix" + i), "prefix" + i, "prefix" + i);
334+
new PrefixLogger(LogManager.getLogger("logger" + i), "prefix" + i);
336335
}
337336

338337
System.gc(); // this will free the weakly referenced keys in the marker cache

qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecatedQueryBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
package org.elasticsearch.http;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.apache.lucene.search.Query;
2324
import org.elasticsearch.common.ParsingException;
2425
import org.elasticsearch.common.io.stream.StreamInput;
2526
import org.elasticsearch.common.io.stream.StreamOutput;
2627
import org.elasticsearch.common.logging.DeprecationLogger;
27-
import org.elasticsearch.common.logging.Loggers;
2828
import org.elasticsearch.common.lucene.search.Queries;
2929
import org.elasticsearch.common.xcontent.XContentBuilder;
3030
import org.elasticsearch.common.xcontent.XContentParser;
@@ -41,7 +41,8 @@
4141
public class TestDeprecatedQueryBuilder extends AbstractQueryBuilder<TestDeprecatedQueryBuilder> {
4242
public static final String NAME = "deprecated_match_all";
4343

44-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(TestDeprecatedQueryBuilder.class));
44+
private static final DeprecationLogger DEPRECATION_LOGGER =
45+
new DeprecationLogger(LogManager.getLogger(TestDeprecatedQueryBuilder.class));
4546

4647
public TestDeprecatedQueryBuilder() {
4748
// nothing to do

server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.action.bulk;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.elasticsearch.action.ActionRequest;
2324
import org.elasticsearch.action.ActionRequestValidationException;
2425
import org.elasticsearch.action.CompositeIndicesRequest;
@@ -37,7 +38,6 @@
3738
import org.elasticsearch.common.io.stream.StreamInput;
3839
import org.elasticsearch.common.io.stream.StreamOutput;
3940
import org.elasticsearch.common.logging.DeprecationLogger;
40-
import org.elasticsearch.common.logging.Loggers;
4141
import org.elasticsearch.common.lucene.uid.Versions;
4242
import org.elasticsearch.common.unit.TimeValue;
4343
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
@@ -67,7 +67,7 @@
6767
*/
6868
public class BulkRequest extends ActionRequest implements CompositeIndicesRequest, WriteRequest<BulkRequest> {
6969
private static final DeprecationLogger DEPRECATION_LOGGER =
70-
new DeprecationLogger(Loggers.getLogger(BulkRequest.class));
70+
new DeprecationLogger(LogManager.getLogger(BulkRequest.class));
7171

7272
private static final int REQUEST_OVERHEAD = 50;
7373

server/src/main/java/org/elasticsearch/action/search/SearchRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.action.search;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.elasticsearch.Version;
2324
import org.elasticsearch.action.ActionRequest;
2425
import org.elasticsearch.action.ActionRequestValidationException;
@@ -29,7 +30,6 @@
2930
import org.elasticsearch.common.io.stream.StreamInput;
3031
import org.elasticsearch.common.io.stream.StreamOutput;
3132
import org.elasticsearch.common.logging.DeprecationLogger;
32-
import org.elasticsearch.common.logging.Loggers;
3333
import org.elasticsearch.common.unit.TimeValue;
3434
import org.elasticsearch.common.xcontent.ToXContent;
3535
import org.elasticsearch.search.Scroll;
@@ -58,7 +58,7 @@
5858
* @see SearchResponse
5959
*/
6060
public final class SearchRequest extends ActionRequest implements IndicesRequest.Replaceable {
61-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(SearchRequest.class));
61+
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(SearchRequest.class));
6262

6363
private static final ToXContent.Params FORMAT_PARAMS = new ToXContent.MapParams(Collections.singletonMap("pretty", "false"));
6464

server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.elasticsearch.action.update;
2121

22-
import java.util.Arrays;
22+
import org.apache.logging.log4j.LogManager;
2323
import org.elasticsearch.action.ActionRequestValidationException;
2424
import org.elasticsearch.action.DocWriteRequest;
2525
import org.elasticsearch.action.index.IndexRequest;
@@ -32,7 +32,6 @@
3232
import org.elasticsearch.common.io.stream.StreamInput;
3333
import org.elasticsearch.common.io.stream.StreamOutput;
3434
import org.elasticsearch.common.logging.DeprecationLogger;
35-
import org.elasticsearch.common.logging.Loggers;
3635
import org.elasticsearch.common.lucene.uid.Versions;
3736
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
3837
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -49,6 +48,7 @@
4948
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
5049

5150
import java.io.IOException;
51+
import java.util.Arrays;
5252
import java.util.Collections;
5353
import java.util.HashMap;
5454
import java.util.List;
@@ -60,7 +60,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
6060
implements DocWriteRequest<UpdateRequest>, WriteRequest<UpdateRequest>, ToXContentObject {
6161

6262
private static final DeprecationLogger DEPRECATION_LOGGER =
63-
new DeprecationLogger(Loggers.getLogger(UpdateRequest.class));
63+
new DeprecationLogger(LogManager.getLogger(UpdateRequest.class));
6464

6565
private String type;
6666
private String id;

server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.action.update;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.elasticsearch.action.index.IndexRequest;
2324
import org.elasticsearch.action.support.ActiveShardCount;
2425
import org.elasticsearch.action.support.WriteRequestBuilder;
@@ -27,7 +28,6 @@
2728
import org.elasticsearch.client.ElasticsearchClient;
2829
import org.elasticsearch.common.Nullable;
2930
import org.elasticsearch.common.logging.DeprecationLogger;
30-
import org.elasticsearch.common.logging.Loggers;
3131
import org.elasticsearch.common.xcontent.XContentBuilder;
3232
import org.elasticsearch.common.xcontent.XContentType;
3333
import org.elasticsearch.index.VersionType;
@@ -38,7 +38,7 @@
3838
public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<UpdateRequest, UpdateResponse, UpdateRequestBuilder>
3939
implements WriteRequestBuilder<UpdateRequestBuilder> {
4040
private static final DeprecationLogger DEPRECATION_LOGGER =
41-
new DeprecationLogger(Loggers.getLogger(UpdateRequestBuilder.class));
41+
new DeprecationLogger(LogManager.getLogger(UpdateRequestBuilder.class));
4242

4343
public UpdateRequestBuilder(ElasticsearchClient client, UpdateAction action) {
4444
super(client, action, new UpdateRequest());

server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.cluster.routing;
2121

22+
import org.apache.logging.log4j.LogManager;
2223
import org.elasticsearch.ExceptionsHelper;
2324
import org.elasticsearch.Version;
2425
import org.elasticsearch.cluster.ClusterState;
@@ -29,7 +30,6 @@
2930
import org.elasticsearch.common.io.stream.StreamOutput;
3031
import org.elasticsearch.common.io.stream.Writeable;
3132
import org.elasticsearch.common.logging.DeprecationLogger;
32-
import org.elasticsearch.common.logging.Loggers;
3333
import org.elasticsearch.common.settings.Setting;
3434
import org.elasticsearch.common.settings.Setting.Property;
3535
import org.elasticsearch.common.settings.Settings;
@@ -50,7 +50,7 @@
5050
*/
5151
public final class UnassignedInfo implements ToXContentFragment, Writeable {
5252

53-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(UnassignedInfo.class));
53+
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(UnassignedInfo.class));
5454

5555
public static final DateFormatter DATE_TIME_FORMATTER = DateFormatters.forPattern("dateOptionalTime").withZone(ZoneOffset.UTC);
5656

server/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)