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

No appenders could be found for logger (common) printed out #17819

Closed
javanna opened this issue Apr 18, 2016 · 2 comments
Closed

No appenders could be found for logger (common) printed out #17819

javanna opened this issue Apr 18, 2016 · 2 comments
Labels
>bug :Core/Infra/Logging Log management and logging utilities

Comments

@javanna
Copy link
Member

javanna commented Apr 18, 2016

If I turn off my wi-fi connection and run elasticsearch, tried with 1.7, 2.3 and 5.0 and it is always the same, the process prints out the following to start with:

log4j:WARN No appenders could be found for logger (common).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

The logging.yml is the default one. After that everything looks ok, usual logging etc.. I guess this is due to the order of initialization of our logging, we may be ok with this initial warning but maybe there is something that we want to do about it.

@jasontedor
Copy link
Member

jasontedor commented Apr 18, 2016

This one is fun. The trouble starts in the innocuous looking line 199 Bootstrap.java:

199:        if (Strings.hasLength(pidFile)) {

This triggers class initialization for Strings which causes the field TIME_UUID_GENERATOR to be initialized on line 64:

64:    private static final UUIDGenerator TIME_UUID_GENERATOR = new TimeBasedUUIDGenerator();

This in turn triggers class initialization for TimeBasedUUIDGenerator which causes the field secureMungedAddressed to be initialized on line 38:

38:    private static final byte[] secureMungedAddress = MacAddressProvider.getSecureMungedAddress();

Now the coup de grâce. The method MacAddressProvider#getSecureMungedAddress tries to get a secure MAC address for use in generating the time-based UUIDs. If all the network interfaces are disabled, then there is no MAC address to use so the check on line 73 passes:

73:        if (!isValidAddress(address)) {

which leads to the fatal logging statement on line 74:

74:             logger.warn("Unable to get a valid mac address, will use a dummy address");

This line being fatal because it's invoked before logging has been initialized.

Two lessons:

  1. static is evil, don't do static
  2. logging in static methods using a statically-initialized static logger (instead of an instance of logger from an AbstractComponent) is prone to this problem

I opened #17837.

@javanna
Copy link
Member Author

javanna commented Apr 19, 2016

This one is fun.

Sounds like it, thanks a lot for digging and fixing @jasontedor

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
Projects
None yet
Development

No branches or pull requests

2 participants