# How do I get to see elasticsearch own logs in a dockerized elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [June 12, 2020, 7:00am UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839 "2020-06-12T07:00:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![smm](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@smm](https://discuss.elastic.co/u/smm)\
**Post date:** [June 12, 2020, 7:00am UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/1 "2020-06-12T07:00:57Z")

</div>

Dear community, i dockerized elasticsearch like this:

esnode1:  
image: [docker.elastic.co/elasticsearch/elasticsearch:7.7.1](http://docker.elastic.co/elasticsearch/elasticsearch:7.7.1)  
container\_name: esnode1  
environment:  
- node.name=esnode1  
- cluster.name=es-on-docker  
- discovery.seed\_hosts=esnode2,esnode3  
- cluster.initial\_master\_nodes=esnode1,esnode2,esnode3  
- cluster.name=docker-cluster  
- bootstrap.memory\_lock=true  
- "ES\_JAVA\_OPTS=-Xms512m -Xmx512m"  
ulimits:  
memlock:  
soft: -1  
hard: -1  
volumes:  
- node1data:/usr/share/elasticsearch/data  
- node1logs:/usr/share/elasticsearch/logs  
- ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml  
ports:  
- 9200:9200  
networks:  
- elasticnet

ubuntu@smp-dev-dockerized-fra11-1:~/docker/config$ cat elasticsearch.yml  
cluster.name: "docker-cluster"  
network.host: 0.0.0.0  
path.logs: /usr/share/elasticsearch/logs

But under the /usr/share/elasticsearch/logs/ in the container (or on the mapped host) I only see gc.log(s) and NOT the 'normal' elasticsearch logs. How do I configure elasticsearch to get ALSO the its own, normal logs I usally have in non-docker elastic nodes? I hope I could make myself clear.  
Thank you and kind regards  
Stefano

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [June 14, 2020, 9:07pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/2 "2020-06-14T21:07:29Z")

</div>

Try docker logs

```auto
docker logs <container_id>

```

---

<div class="post-metadata">

**Author:** ![StefanoM](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@StefanoM](https://discuss.elastic.co/u/StefanoM)\
**Post date:** [June 15, 2020, 6:55am UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/3 "2020-06-15T06:55:29Z")

</div>

Thanks, docke logs worked, but I am still wondetting: if I go into the machine with docker exec -it bash and navigate to the usal logs directory I only see the gc.log and not the logs that I see with docker logs. Why is it so? Is there a possibility to have the logs in both ways / locations at the same time?  
Thanks

---

<div class="post-metadata">

**Author:** ![gab.bernasconi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gab.bernasconi/32/57955_2.png) [@gab.bernasconi](https://discuss.elastic.co/u/gab.bernasconi)\
**Post date:** [June 15, 2020, 10:08am UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/4 "2020-06-15T10:08:52Z")

</div>

Hi,

we are actually doing this in production. We use the following configuration:

See this `docker-compose.yml` snippet:

```auto
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2
    volumes:
      - <local data folder path>:/usr/share/elasticsearch/data
      - <local logs folder path>:/usr/share/elasticsearch/logs
      - <local elasticsearch.yml>:/usr/share/elasticsearch/config/elasticsearch.yml
      - <local log4j2.properties>:/usr/share/elasticsearch/config/log4j2.properties

```

By doing this, you can freely configure `log4j2.properties` to configure logging in any way you please, and `docker-compose logs` (or `docker logs`) still works as expected.

---

<div class="post-metadata">

**Author:** ![StefanoM](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@StefanoM](https://discuss.elastic.co/u/StefanoM)\
**Post date:** [June 15, 2020, 12:30pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/5 "2020-06-15T12:30:29Z")

</div>

Dear Gabriele,

thanks for your input - I will try it that way.  
Saluti,  
Stefano

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [June 15, 2020, 1:08pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/6 "2020-06-15T13:08:15Z")

</div>

> > Why is it so?

config/log4j2.properties in the docker image only enables console logging. Docker makes container's console logs available via `docker logs`.

Even if a container fails to start you can get console logs to debug the issue as docker retains those for some time. If logs are stored only in a container directory (not mounted) you will lose these logs if the container fails to start or after it terminates.

---

<div class="post-metadata">

**Author:** ![smm](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@smm](https://discuss.elastic.co/u/smm)\
**Post date:** [June 19, 2020, 10:45am UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/7 "2020-06-19T10:45:11Z")

</div>

That makes sense - thanks all for the inputs.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 17, 2020, 10:45am UTC](https://discuss.elastic.co/t/how-do-i-get-to-see-elasticsearch-own-logs-in-a-dockerized-elasticsearch/236839/8 "2020-07-17T10:45:19Z")

</div>

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