# Log4j Configuration

**URL:** <https://discuss.elastic.co/t/log4j-configuration/220565>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [February 23, 2020, 6:07pm UTC](https://discuss.elastic.co/t/log4j-configuration/220565 "2020-02-23T18:07:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtapia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dtapia/32/85717_2.png) [@dtapia](https://discuss.elastic.co/u/dtapia)\
**Post date:** [February 23, 2020, 6:07pm UTC](https://discuss.elastic.co/t/log4j-configuration/220565/1 "2020-02-23T18:07:37Z")

</div>

I need to edit the log4j configuration in log4j.properties, the file is editible if I exec into it but the changes dont persist accross pod restarts. Is there a way to configure this through the operator or a yaml file?

---

<div class="post-metadata">

**Author:** ![michael.morello](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.morello/32/47448_2.png) [@michael.morello](https://discuss.elastic.co/u/michael.morello)\
**Post date:** [February 24, 2020, 8:16am UTC](https://discuss.elastic.co/t/log4j-configuration/220565/2 "2020-02-24T08:16:57Z")

</div>

The `log4j2.properties` configuration file is part of the container and is ephemeral as any file that is not mounted in a volume.

If you want to change the logging levels I would suggest to first try to use the command-line options or use the cluster settings as described in the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/logging.html#configuring-logging-levels).

If you really know what you are doing you can override the log4j2 configuration using a configMap with something like:

```auto
$ kubectl create configmap log4j --from-file=log4j2.properties=/path/to/my/log4j2.properties

```

Then mount the configmap:

```auto
    podTemplate:
      spec:
        containers:
        - name: elasticsearch
          volumeMounts:
          - mountPath: /usr/share/elasticsearch/config/log4j2.properties
            subPath: log4j2.properties
            name: log4j
        volumes:
        - name: log4j
          configMap:
            name: log4j

```

---

<div class="post-metadata">

**Author:** ![dtapia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dtapia/32/85717_2.png) [@dtapia](https://discuss.elastic.co/u/dtapia)\
**Post date:** [February 24, 2020, 2:52pm UTC](https://discuss.elastic.co/t/log4j-configuration/220565/3 "2020-02-24T14:52:19Z")

</div>

> [@michael.morello](#):
>
> log4j

Thank you, this was very helpful, really appreciate it!

---

<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:** [November 4, 2022, 7:46am UTC](https://discuss.elastic.co/t/log4j-configuration/220565/4 "2022-11-04T07:46:20Z")

</div>


