Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch can't write to log files

I would like to activate logs of elasticsearch .

When I run elasticsearch binaries, I realize that I have problems with logging : the configuration cannot be loaded !

Here is the output :

~ $ sudo /usr/share/elasticsearch/bin/elasticsearch
Failed to configure logging...
org.elasticsearch.ElasticsearchException: Failed to load logging configuration
    at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:117)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:81)
    at org.elasticsearch.bootstrap.Bootstrap.setupLogging(Bootstrap.java:94)
    at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:178)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)
Caused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
    at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:97)
    at java.nio.file.Files.readAttributes(Files.java:1686)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:109)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
    at java.nio.file.Files.walkFileTree(Files.java:2602)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:107)
    ... 4 more
log4j:WARN No appenders could be found for logger (node).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Java HotSpot(TM) Server VM warning: You have loaded library /usr/share/elasticsearch/lib/sigar/libsigar-x86-linux.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.

I am running under linuxmint 17 and using latest ES.

like image 724
4m1nh4j1 Avatar asked Jul 26 '14 21:07

4m1nh4j1


People also ask

How do I write logs in Elasticsearch?

Airflow can be configured to read task logs from Elasticsearch and optionally write logs to stdout in standard or json format. These logs can later be collected and forwarded to the Elasticsearch cluster using tools like fluentd, logstash or others.

Is Elasticsearch using Log4j?

Elasticsearch uses Log4j 2 for logging. Log4j 2 can be configured using the log4j2. properties file.

Is Elasticsearch good for logging?

Elasticsearch, which stores and searches documents, along with its ability to scale over huge volume of data, is a good candidate for inclusion in an application log analytics solution.


3 Answers

If you installed elasticsearch using a package manager like yum or apt-get you should not start elasticsearch this way. Try to use the service: for instance /etc/init.d/elasticsearch or using the command sudo service elasticsearch start

You should also check if the logging.yml file is at the location mentioned in the stack trace:/usr/share/elasticsearch/config

Using sudo to start elasticsearch is not good, you could do sudo elasticsearch to run as the elasticsearch user, but I prefer to use the service call as described in the second sentence.

Hope that helps

like image 181
Jettro Coenradie Avatar answered Oct 18 '22 00:10

Jettro Coenradie


Your elasticsearch.yml file as well as logging.yml file will be in the /etc/elasticsearch folder.

Create a config folder in your elasticsearch folder in /usr/share and move the .yml files to the config folder

Now run /bin/elasticsearch start and it will work.

like image 10
user3890091 Avatar answered Oct 18 '22 01:10

user3890091


Following this worked for me.

Your elasticsearch.yml file as well as logging.yml file will be in the /etc/elasticsearch folder.

Create a config folder in your elasticsearch folder in /usr/share and move the .yml files to the config folder

like image 7
Kwame Avatar answered Oct 18 '22 02:10

Kwame