Skip to content

Commit

Permalink
Initialise ES logging in CLI (#97353) (#97366)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pgomulka committed Jul 4, 2023
1 parent 5663098 commit d8a2999
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ private static void configureLoggingWithoutConfig(Map<String, String> sysprops)
final String loggerLevel = sysprops.getOrDefault("es.logger.level", Level.INFO.name());
final Settings settings = Settings.builder().put("logger.level", loggerLevel).build();
LogConfigurator.configureWithoutConfig(settings);
// a temporary fix to allow a cli-launcher.jar replacement. That method should is called in configureWithoutConfig
LogConfigurator.configureESLogging();
}

/**
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/97353.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 97353
summary: Initialise ES logging in CLI
area: Infra/CLI
type: bug
issues:
- 97350
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public static void registerErrorListener() {
*/
public static void configureWithoutConfig(final Settings settings) {
Objects.requireNonNull(settings);
configureESLogging();
// we initialize the status logger immediately otherwise Log4j will complain when we try to get the context
configureStatusLogger();
configureLoggerLevels(settings);
Expand Down

0 comments on commit d8a2999

Please sign in to comment.