Skip to content

Commit e38d20c

Browse files
committed
Just set log level to debug
1 parent 79a06aa commit e38d20c

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/SearchErrorTraceIT.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.apache.http.entity.ContentType;
1313
import org.apache.http.nio.entity.NByteArrayEntity;
1414
import org.apache.logging.log4j.Level;
15-
import org.apache.logging.log4j.LogManager;
1615
import org.apache.logging.log4j.core.config.Configurator;
1716
import org.elasticsearch.action.search.MultiSearchRequest;
1817
import org.elasticsearch.action.search.SearchRequest;
@@ -27,7 +26,6 @@
2726
import org.elasticsearch.test.MockLog;
2827
import org.elasticsearch.test.transport.MockTransportService;
2928
import org.elasticsearch.xcontent.XContentType;
30-
import org.junit.AfterClass;
3129
import org.junit.Before;
3230
import org.junit.BeforeClass;
3331

@@ -41,23 +39,14 @@
4139
public class SearchErrorTraceIT extends HttpSmokeTestCase {
4240
private BooleanSupplier hasStackTrace;
4341

44-
private static final String loggerName = "org.elasticsearch.search.SearchService";
45-
private static Level originalLogLevel;
46-
4742
@Override
4843
protected Collection<Class<? extends Plugin>> nodePlugins() {
4944
return CollectionUtils.appendToCopyNoNullElements(super.nodePlugins(), MockTransportService.TestPlugin.class);
5045
}
5146

5247
@BeforeClass
5348
public static void setDebugLogLevel() {
54-
originalLogLevel = LogManager.getLogger(loggerName).getLevel();
55-
Configurator.setLevel(loggerName, Level.DEBUG);
56-
}
57-
58-
@AfterClass
59-
public static void resetLogLevel() {
60-
Configurator.setLevel(loggerName, originalLogLevel);
49+
Configurator.setLevel("org.elasticsearch.search.SearchService", Level.DEBUG);
6150
}
6251

6352
@Before

server/src/test/java/org/elasticsearch/search/SearchServiceTests.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.search;
1111

1212
import org.apache.logging.log4j.Level;
13-
import org.apache.logging.log4j.LogManager;
1413
import org.apache.logging.log4j.core.config.Configurator;
1514
import org.apache.lucene.index.LeafReaderContext;
1615
import org.apache.lucene.search.IndexSearcher;
@@ -183,10 +182,8 @@ public void testMaybeWrapListenerForStackTraceLogs() {
183182
null
184183
);
185184

186-
final String loggerName = "org.elasticsearch.search.SearchService";
187-
Level originalLogLevel = LogManager.getLogger(loggerName).getLevel();
188185
try (var mockLog = MockLog.capture(SearchService.class)) {
189-
Configurator.setLevel(loggerName, Level.DEBUG);
186+
Configurator.setLevel("org.elasticsearch.search.SearchService", Level.DEBUG);
190187
final String exceptionMessage = "test exception message";
191188
mockLog.addExpectation(
192189
new MockLog.PatternAndExceptionSeenEventExpectation(
@@ -214,8 +211,6 @@ public void onFailure(Exception e) {
214211
Exception e = new Exception(exceptionMessage);
215212
listener = maybeWrapListenerForStackTrace(listener, shardRequest, threadPool, createClusterService(threadPool));
216213
listener.onFailure(e);
217-
} finally {
218-
Configurator.setLevel(loggerName, originalLogLevel);
219214
}
220215
}
221216

x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchErrorTraceIT.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.elasticsearch.xpack.search;
99

1010
import org.apache.logging.log4j.Level;
11-
import org.apache.logging.log4j.LogManager;
1211
import org.apache.logging.log4j.core.config.Configurator;
1312
import org.elasticsearch.client.Request;
1413
import org.elasticsearch.client.Response;
@@ -24,7 +23,6 @@
2423
import org.elasticsearch.test.MockLog;
2524
import org.elasticsearch.test.transport.MockTransportService;
2625
import org.elasticsearch.xcontent.XContentType;
27-
import org.junit.AfterClass;
2826
import org.junit.Before;
2927
import org.junit.BeforeClass;
3028

@@ -36,9 +34,6 @@
3634
public class AsyncSearchErrorTraceIT extends ESIntegTestCase {
3735
private BooleanSupplier transportMessageHasStackTrace;
3836

39-
private static final String loggerName = "org.elasticsearch.search.SearchService";
40-
private static Level originalLogLevel;
41-
4237
@Override
4338
protected boolean addMockHttpTransport() {
4439
return false; // enable http
@@ -52,13 +47,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
5247

5348
@BeforeClass
5449
public static void setDebugLogLevel() {
55-
originalLogLevel = LogManager.getLogger(loggerName).getLevel();
56-
Configurator.setLevel(loggerName, Level.DEBUG);
57-
}
58-
59-
@AfterClass
60-
public static void resetLogLevel() {
61-
Configurator.setLevel(loggerName, originalLogLevel);
50+
Configurator.setLevel("org.elasticsearch.search.SearchService", Level.DEBUG);
6251
}
6352

6453
@Before

0 commit comments

Comments
 (0)