Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR Unable to locate plugin type [for RollingFile and for TimeBasedTriggeringPolicy]

I'm starting to work a docker elasticsearch 5.0.1 instance following the official instructions detailed at:

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/settings.html

in order to configure elasticsearch.yml and log4j2.properties files, those files are located at:

$ pwd
/system/mesos/elasticsearchf/config
$ ls
elasticsearch.yml log4j2.properties

Contain of these configuration files:

$cat elasticsearch.yml
path:
data: /usr/share/elasticsearch/data
logs: /usr/share/elasticsearch/data
shared_data: /usr/share/elasticsearch/data
config: /usr/share/elasticsearch/config

node.add_lock_id_to_custom_path: false
index.number_of_shards: 2
cluster.name: elasticcluster
discovery.zen.ping.unicast.hosts: ["10.120.1.190", "10.120.1.191"]

$cat log4j2.properties
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %.10000m%n
appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true

And when I run command:

$ docker -D -H unix:///var/run/docker.sock run --cpu-shares 1024 --memory 2634022912 -e ES_JAVA_OPTS="-Xms2G -Xmx2G" -v /system/mesos/elasticsearchf/data:/usr/share/elasticsearch/data/:rw -v /system/mesos/elasticsearchf/config:/usr/share/elasticsearch/config/:rw --net bridge -p 9200:9200/tcp -p 9300:9300/tcp docker.elastic.co/elasticsearch/elasticsearch:5.0.1

I got error messages related with log4j2 messages you can see below

Any help will be welcome

Kind Regards

DEBU[0001] framesize: 81
2016-12-01 10:37:15,526 main ERROR Unable to locate plugin type for RollingFile
DEBU[0001] framesize: 90
2016-12-01 10:37:15,554 main ERROR Unable to locate plugin for TimeBasedTriggeringPolicy
DEBU[0001] framesize: 2223
2016-12-01 10:37:15,555 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy for element Policies. java.lang.NullPointerException
        at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:243)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:131)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:249)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:116)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:83)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:249)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103)
        at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
        at org.elasticsearch.cli.Command.main(Command.java:62)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73)

DEBU[0001] framesize: 76
2016-12-01 10:37:15,557 main ERROR Unable to locate plugin for RollingFile
DEBU[0001] framesize: 1974
2016-12-01 10:37:15,558 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.config.AppendersPlugin for element Appenders. java.lang.NullPointerException
        at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:243)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:131)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:249)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:116)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:83)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:249)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103)
        at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
        at org.elasticsearch.cli.Command.main(Command.java:62)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73)

DEBU[0002] Corrupted prefix: []
DEBU[0002] [hijack] End of stdout
like image 562
cruizpollino Avatar asked Dec 01 '16 11:12

cruizpollino


2 Answers

I encountered exactly the same error when trying to run Elasticsearch 5.3 on Docker and I was using similar properties as mentioned in the Elasticsearch logging configuration section. It took me a while to find out why I was getting this error. It is because of a space at the end of the line when defining the type properties. There should not be any space at the end of the lines.

appender.rolling.type = RollingFile
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy

Once you remove the spaces (with the configuration mentioned above in the question) your Elasticsearch will come up but you will still get no log as it overrides the default setting for showing the error in console and the rolling appender is also not added to the root logger. To see the log info gets generated you need the following 2 lines to be added to your log4j2.properties as well

rootLogger.level = info
rootLogger.appenderRef.rolling.ref = rolling
like image 157
Navid H Avatar answered Sep 21 '22 07:09

Navid H


As the Elasticsearch documentation says :

Log4j’s configuration parsing gets confused by any extraneous whitespace; if you copy and paste any Log4j settings on this page, or enter any Log4j configuration in general, be sure to trim any leading and trailing whitespace.

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/logging.html

like image 45
Orakler Avatar answered Sep 20 '22 07:09

Orakler