Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for disabling console logging #117665

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/117665.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117665
summary: Add setting for disabling console logging
area: Infra/Logging
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ public void checkPermission(Permission perm) {
BootstrapInfo.setConsole(ConsoleLoader.loadConsole(nodeEnv));

// DO NOT MOVE THIS
// Logging must remain the last step of phase 1. Anything init steps needing logging should be in phase 2.
// Logging must remain the last step of phase 1. Any init steps needing logging should be in phase 2.
LogConfigurator.setNodeName(Node.NODE_NAME_SETTING.get(args.nodeSettings()));
LogConfigurator.configure(nodeEnv, args.quiet() == false);
boolean console = args.quiet() == false && LogConfigurator.CONSOLE_ENABLED.get(args.nodeSettings());
LogConfigurator.configure(nodeEnv, console);
} catch (Throwable t) {
// any exception this early needs to be fully printed and fail startup
t.printStackTrace(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.logging.log4j.util.Unbox;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.logging.internal.LoggerFactoryImpl;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.env.Environment;
Expand Down Expand Up @@ -84,6 +85,8 @@ public void log(StatusData data) {

private static Appender consoleAppender;

public static final Setting<Boolean> CONSOLE_ENABLED = Setting.boolSetting("logging.console.enabled", true, Setting.Property.NodeScope);

/**
* Registers a listener for status logger errors. This listener should be registered as early as possible to ensure that no errors are
* logged by the status logger before logging is configured.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.elasticsearch.cluster.service.ClusterApplierService;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.cluster.service.MasterService;
import org.elasticsearch.common.logging.LogConfigurator;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.network.NetworkService;
Expand Down Expand Up @@ -479,6 +480,7 @@ public void apply(Settings value, Settings current, Settings previous) {
Node.NODE_EXTERNAL_ID_SETTING,
Node.NODE_NAME_SETTING,
Node.NODE_ATTRIBUTES,
LogConfigurator.CONSOLE_ENABLED,
NodeRoleSettings.NODE_ROLES_SETTING,
AutoCreateIndex.AUTO_CREATE_INDEX_SETTING,
BaseRestHandler.MULTI_ALLOW_EXPLICIT_INDEX,
Expand Down