Elasticsearch v6.2 ERROR No log4j2 configuration file found

I'm following the instructions in order to install elasticsearch on an amazon ec2 instance. I have installed this elasticsearch version and also two plugins. Also I have updated the java version to this.

And when I try to start elasticsearch with sudo service elasticsearch start I get the following error:

[ec2-user@ip-xxx-xx-x-xxx src]$ sudo service elasticsearch start
Starting elasticsearch: Exception in thread "main" 2018-05-17 
07:52:11,411 main ERROR No log4j2 configuration file found. Using
default configuration: logging only errors to the console. Set system
property 'log4j2.debug' to show Log4j2 internal initialization 
logging.
ElasticsearchParseException[malformed, expected end of settings but
encountered additional content starting at line number: [33], column 
number: [1]]; nested: MarkedYAMLException[expected '<document 
start>', but found BlockMappingStart
in 'reader', line 33, column 1:
path.data: /var/lib/elasticsearch
^

at [Source: sun.nio.ch.ChannelInputStream@1fa121e2; line: 33, column: 
1]]; nested: ParserException[expected '<document start>', but found 
BlockMappingStart
in 'reader', line 33, column 1:
path.data: /var/lib/elasticsearch
^
];
at 
org.elasticsearch.common.settings.Settings.fromXContent
(Settings.java:683)
at org.elasticsearch.common.settings.Settings.access$500
(Settings.java:82)
at org.elasticsearch.common.settings.Settings$Builder.loadFromStream
(Settings.java:1183)
at org.elasticsearch.common.settings.Settings$Builder.loadFromPath
(Settings.java:1162)
at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment
(InternalSettingsPreparer.java:99)
at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv
(EnvironmentAwareCommand.java:95)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute
(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling
(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main
(Elasticsearch.java:92)
at org.elasticsearch.bootstrap.Elasticsearch.main
(Elasticsearch.java:85)
Caused by:  
com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.
MarkedYAMLException: expected '<document start>', but found   

BlockMappingStart
in 'reader', line 33, column 1:
path.data: /var/lib/elasticsearch
^

at [Source: sun.nio.ch.ChannelInputStream@1fa121e2; line: 33, column: 1]
at com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.
MarkedYAMLException.from(MarkedYAMLException.java:27)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken
(YAMLParser.java:343)
at  
org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken
(JsonXContentParser.java:52)
at org.elasticsearch.common.settings.Settings.fromXContent
(Settings.java:678)
... 10 more
Caused by: expected '<document start>', but found BlockMappingStart
in 'reader', line 33, column 1:
path.data: /var/lib/elasticsearch
^

at org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentStart.produce
(ParserImpl.java:224)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent
(ParserImpl.java:157)
at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:167)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken
(YAMLParser.java:340)
... 12 more

How can I solve this issue?

I tried the following but still got the same error. I added the log4j2.xml and log4j2.properties files to the src/main/resources path.

log4j2.xml

<dependency>
  <groupId>org.apache.logging.log4j</groupId>
  <artifactId>log4j-core</artifactId>
  <version>2.9.1</version>
</dependency>

log4j2.properties

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout

rootLogger.level = info
rootLogger.appenderRef.console.ref = console

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.