Skip to content

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

Merged
merged 1 commit into from
Oct 6, 2015

Conversation

brwe
Copy link
Contributor

@brwe brwe commented Oct 5, 2015

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.

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");
Copy link
Member

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) {
Copy link
Member

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.

@spinscale
Copy link
Contributor

left some minor comments, agreeing with the others, but this looks good. thx for digging!

@brwe brwe force-pushed the plugin-cli-logging branch from e0975b1 to 0317de1 Compare October 5, 2015 15:14
@brwe
Copy link
Contributor Author

brwe commented Oct 5, 2015

@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.
Copy link
Member

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.

@nik9000
Copy link
Member

nik9000 commented Oct 5, 2015

LGTM

@brwe brwe force-pushed the plugin-cli-logging branch from 208e748 to 3e4976d Compare October 6, 2015 11:50
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.
@brwe brwe force-pushed the plugin-cli-logging branch from 3e4976d to 9492be6 Compare October 6, 2015 12:13
brwe added a commit that referenced this pull request Oct 6, 2015
plugin cli tool should not create empty log files
@brwe brwe merged commit d2ca694 into elastic:master Oct 6, 2015
@clintongormley clintongormley changed the title plugin cli tool should not create empty log files Plugin cli tool should not create empty log files Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Logging Log management and logging utilities v2.0.0 v2.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants