Skip to content

Commit 3e804bd

Browse files
authored
Initialise ES logging in CLI (#97353)
ES logging has to be explicitly initialised with a call to LoggerFactory.setInstance This is normally done as LogConfigurator.configure(Environment,boolean) is calling this as part of initPhase1 However CLI tools were not using that method. Cli tools are using LogConfigurator.configureWithoutConfig and that method was not setting up ES logging This commit modifies configureWithoutConfig to also configure esLogging It also adds a LogConfigurator.configureESLogging call explicitly in CliToolLauncher This allows to build a new cli-launcher.jar and replace it in previous 8.7-8.9 clusters closes #97350
1 parent b862707 commit 3e804bd

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

distribution/tools/cli-launcher/src/main/java/org/elasticsearch/launcher/CliToolLauncher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ private static void configureLoggingWithoutConfig(Map<String, String> sysprops)
112112
final String loggerLevel = sysprops.getOrDefault("es.logger.level", Level.INFO.name());
113113
final Settings settings = Settings.builder().put("logger.level", loggerLevel).build();
114114
LogConfigurator.configureWithoutConfig(settings);
115+
// a temporary fix to allow a cli-launcher.jar replacement. That method should is called in configureWithoutConfig
116+
LogConfigurator.configureESLogging();
115117
}
116118

117119
/**

docs/changelog/97353.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 97353
2+
summary: Initialise ES logging in CLI
3+
area: Infra/CLI
4+
type: bug
5+
issues:
6+
- 97350

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public static void registerErrorListener() {
100100
*/
101101
public static void configureWithoutConfig(final Settings settings) {
102102
Objects.requireNonNull(settings);
103+
configureESLogging();
103104
// we initialize the status logger immediately otherwise Log4j will complain when we try to get the context
104105
configureStatusLogger();
105106
configureLoggerLevels(settings);

0 commit comments

Comments
 (0)