# Log4j2.properties удаление логов

**URL:** <https://discuss.elastic.co/t/log4j2-properties/253557>\
**Category:** Вопросы на русском языке\
**Created:** [October 28, 2020, 12:34pm UTC](https://discuss.elastic.co/t/log4j2-properties/253557 "2020-10-28T12:34:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![es7x](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@es7x](https://discuss.elastic.co/u/es7x)\
**Post date:** [October 28, 2020, 12:34pm UTC](https://discuss.elastic.co/t/log4j2-properties/253557/1 "2020-10-28T12:34:30Z")

</div>

Подскажите, файл log4j2.properties

```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}_server.json
appender.rolling.layout.type = ESJsonLayout
appender.rolling.layout.type_name = server

appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.json.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
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basepath = ${sys:es.logs.base_path}
appender.rolling.strategy.action.condition.type = IfFileName
appender.rolling.strategy.action.condition.glob = ${sys:es.logs.cluster_name}-*
appender.rolling.strategy.action.condition.nested_condition.type = IfAccumulatedFileSize
appender.rolling.strategy.action.condition.nested_condition.exceeds = 2GB

```

Что нужно изменить, чтобы логи автоматически удалялись например после 7 дней, а то заходишь в логи а там видимо не видимо файлов?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 28, 2020, 3:01pm UTC](https://discuss.elastic.co/t/log4j2-properties/253557/2 "2020-10-28T15:01:40Z")

</div>

Посмотрите 3-й пример в [документации логгера](https://www.elastic.co/guide/en/elasticsearch/reference/master/logging.html#CO6-6) . Вам надо `nested_condition` заменить с размера на время модификации.

---

<div class="post-metadata">

**Author:** ![es7x](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@es7x](https://discuss.elastic.co/u/es7x)\
**Post date:** [October 29, 2020, 8:24am UTC](https://discuss.elastic.co/t/log4j2-properties/253557/3 "2020-10-29T08:24:02Z")

</div>

Спасибо, помогло.

---

<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 26, 2020, 8:24am UTC](https://discuss.elastic.co/t/log4j2-properties/253557/4 "2020-11-26T08:24:02Z")

</div>

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