# Log rotation for cluster log file configure in log4j2 properties

**URL:** <https://discuss.elastic.co/t/log-rotation-for-cluster-log-file-configure-in-log4j2-properties/230227>\
**Category:** Elasticsearch\
**Created:** [April 28, 2020, 5:46pm UTC](https://discuss.elastic.co/t/log-rotation-for-cluster-log-file-configure-in-log4j2-properties/230227 "2020-04-28T17:46:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanjay1](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Sanjay1](https://discuss.elastic.co/u/Sanjay1)\
**Post date:** [April 28, 2020, 5:46pm UTC](https://discuss.elastic.co/t/log-rotation-for-cluster-log-file-configure-in-log4j2-properties/230227/1 "2020-04-28T17:46:44Z")

</div>

We are using the ES 7.4.2  
Our log4j2.properties has the following configuration

Even policy appender.rolling.policies.time.interval = 1 set to 1 day, still log file is not rotated.  
As soon as re restart the elasticsearch service the log file is rotated  
-rw-r--r-- 1 elasticsearch elasticsearch 10152 Apr 28 17:23 es-cluster-loadtest-2020-04-27-1.log.gz  
-rw-r--r-- 1 elasticsearch elasticsearch 11153 Apr 28 17:24 es-cluster-loadtest.log

Please help me so that elasticsearch log rotated daily at beginning of each day. Our servers configure UTC time, we need to get this change at midnight UTC time. Also we do not have to restart the elasticsearch service.

```auto
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
**appender.rolling.policies.time.interval = 1**
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 128MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.fileIndex = nomax

```

---

<div class="post-metadata">

**Author:** ![Sanjay1](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Sanjay1](https://discuss.elastic.co/u/Sanjay1)\
**Post date:** [April 29, 2020, 5:55pm UTC](https://discuss.elastic.co/t/log-rotation-for-cluster-log-file-configure-in-log4j2-properties/230227/2 "2020-04-29T17:55:34Z")

</div>

I really appreciate your reply on my this case.

Please verify my setting of log4j2.properties mention above.

As it is set to time base trigger policy set to 1 day.  
It is still not rotated today. Please help me configuration so log rotation works.

Your early help will be appreciated.

-Sanjay

---

<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:** [May 27, 2020, 5:55pm UTC](https://discuss.elastic.co/t/log-rotation-for-cluster-log-file-configure-in-log4j2-properties/230227/3 "2020-05-27T17:55:38Z")

</div>

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