newuser123123
newuser123123

Reputation: 89

How to set up logging level in Elasticsearch?

Could you tell me how to set up explicitly logging level in Elasticsearch as INFO? I would like to do that in the file: elasticsearch.yaml

Upvotes: 7

Views: 19857

Answers (3)

Val
Val

Reputation: 217304

There are three ways to do it:

A. By updating the cluster settings dynamically (doesn't require any restart):

PUT /_cluster/settings
{
  "transient": {
    "logger.org.elasticsearch.transport": "TRACE"
  }
}

B. By setting the log level directly in elasticsearch.yml (requires restart):

logger.org.elasticsearch.transport: TRACE

C. By setting the log level directly in log4j2.properties (requires restart):

logger.transport.level = trace

Upvotes: 6

ibexit
ibexit

Reputation: 3667

There are serveral ways, all described here.

As you are asking for elasticsearch.yml based config, just pick the according logger based on the source packages here and add sth. like this for the transport layer:

logger.org.elasticsearch.transport: INFO

Adding serveral lines will allow you to define different log levels for different functions:

logger.org.elasticsearch.transport: INFO
logger.org.elasticsearch.http: DEBUG

Upvotes: 1

Aman_Bhala
Aman_Bhala

Reputation: 317

From the docs here: To get more or less verbose logs, use the cluster update settings API to change the related logger’s log level. Each logger accepts Log4j 2’s built-in log levels, from least to most verbose: OFF, FATAL, ERROR, WARN, INFO, DEBUG, and TRACE. The default log level is INFO. Messages logged at higher verbosity levels (DEBUG and TRACE) are only intended for expert use. If you are running elasticsearch inside a pod then shell into the es pod for which you want to change the log level and run the command:

curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "logger.org.elasticsearch.discovery": "DEBUG"
  }
}'

You can do that through Postman Just do a PUT request at the url: http://localhost:9200/_cluster/settings and pass

{
  "persistent": {
    "logger.org.elasticsearch.discovery": "DEBUG"
  }
}

in the json under the raw option. You would see response like this:

{
    "acknowledged": true,
    "persistent": {
        "logger": {
            "org": {
                "elasticsearch": {
                    "discovery": "DEBUG"
                }
            }
        }
    },
    "transient": {}
}

In general, Elasticsearch should be located at localhost:9200 in all ELK Stack configuration files for system-hosted ELK, unless of course you have a different location. Also you can use the elasticsearch.yml and kibana.yml files to increase the verbosity levels:

---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: hulk
spec:
  version: 7.8.0
  nodeSets:
  - name: default
    count: 3
    config:
      logger.org.elasticsearch: warn
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: hulk
spec:
  version: 7.8.0
  count: 1
  elasticsearchRef:
    name: hulk
  config:
    logging.quiet: true

If you would like to use environment variables then you could do something like:

---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: hulk
spec:
  version: 7.8.0
  nodeSets:
  - name: default
    count: 3
    podTemplate:
      spec:
        containers:
          - name: elasticsearch
            env:
              - name: logger.org.elasticsearch
                value: warn
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: hulk
spec:
  version: 7.8.0
  count: 1
  elasticsearchRef:
    name: hulk
  podTemplate:
    spec:
      containers:
        - name: kibana
          env:
            - name: LOGGING_QUIET
              value: "true"

Upvotes: 0

Related Questions