-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Plugin cli tool should not create empty log files #13933
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
Conversation
Environment env = InternalSettingsPreparer.prepareEnvironment(EMPTY, Terminal.DEFAULT); | ||
LogConfigurator.configure(env.settings()); | ||
// initialize default for es.logger.level because we will not read the logging.yml | ||
String loggerLevel = System.getProperty("es.logger.level"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System.getProperty("es.logger.level", "INFO");
configure(settings, true); | ||
} | ||
|
||
public static void configure(Settings settings, boolean resolveConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably deserves javadoc saying that resolveConfig controls if the config file is read or not.
left some minor comments, agreeing with the others, but this looks good. thx for digging! |
e0975b1
to
0317de1
Compare
@dadoonet @nik9000 @spinscale thanks a lot for the review! I addressed all comments. |
@@ -83,15 +84,24 @@ | |||
.put("xml", "org.apache.log4j.XMLLayout") | |||
.immutableMap(); | |||
|
|||
public static void configure(Settings settings) { | |||
/** | |||
* Consolidates settings and converts them into actual log4j settings, then initializes loggers and appenders. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this. Wonderful.
LGTM |
208e748
to
3e4976d
Compare
Plugin cli tools configures logging with whatever is in the logging.yml. If a file appender is configured for any of the logs this will cause creation of an empty log file. If a plugin was for example installed as root it will create empty logs at es.home/logs. This is problematic when for example plugins are installed as root and es is run as service. Logs will then be created in /usr/share/elasticsearch/logs and can later not be removed by for example dpkg -r or -purge. To avoid this, configure the logger to use an appender that writes to the same output that plugin cli tool does. This allows other components that are called from Plugin cli tool to write to the same terminal that plugin cli tool writes to by using the logging mechanism already in place. The logging conf is not read at all pb plugin cli tool. As a side effect, the loging level for components that are called from the plugin command such as the jar hell check can now be configured with -Des.logger.level which makes it easier to debug the jar hell check.
3e4976d
to
9492be6
Compare
plugin cli tool should not create empty log files
Plugin cli tools configures logging with whatever is in the logging.yml.
If a file appender is configured for any of the logs this will cause creation
of an empty log file. If a plugin was for example installed as root it will
create empty logs at es.home/logs.
This is problematic when for example plugins are installed as root and es is run
as service. Logs will then be created in /usr/share/elasticsearch/logs
and can later not be removed by for example dpkg -r or -purge.
To avoid this, configure the logger to use an appender that writes to the same
output that plugin cli tool does. This allows other components that are called
from Plugin cli tool to write to the same terminal that plugin cli tool writes to
by using the logging mechanism already in place.
The logging conf is not read at all pb plugin cli tool.
As a side effect, the loging level for components that are called
from the plugin command such as the jar hell check can now be configured
with -Des.logger.level which makes it easier to debug the jar hell check.