# Logstash log4j2.properties deleting all the compressed files

**URL:** <https://discuss.elastic.co/t/logstash-log4j2-properties-deleting-all-the-compressed-files/290896>\
**Category:** Logstash\
**Created:** [December 3, 2021, 12:33pm UTC](https://discuss.elastic.co/t/logstash-log4j2-properties-deleting-all-the-compressed-files/290896 "2021-12-03T12:33:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tahseen\_fatima](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tahseen_fatima/32/67789_2.png) [@tahseen\_fatima](https://discuss.elastic.co/u/tahseen_fatima)\
**Post date:** [December 3, 2021, 12:33pm UTC](https://discuss.elastic.co/t/logstash-log4j2-properties-deleting-all-the-compressed-files/290896/1 "2021-12-03T12:33:08Z")

</div>

Hi Team,

I am trying to delete the audit files from Elasticsearch logs directory "C:\test-elk\Elasticsearch-7.7.0\data\logs". My audit files are generating to the mentioned path but unfortunately I am not able to delete only the audit files.  
Below are my configuration in log4j.

```auto
appender.audit_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_audit-%d{yyyy-MM-dd}-%i.json.gz
appender.audit_rolling.policies.type = Policies
appender.audit_rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.audit_rolling.policies.time.interval = 1
appender.audit_rolling.policies.time.modulate = true

appender.audit_rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.audit_rolling.policies.size.size = 1KB
appender.audit_rolling.strategy.type = DefaultRolloverStrategy
appender.audit_rolling.strategy.fileIndex = nomax

#If you want to optionally want to delete files 
appender.audit_rolling.strategy.action.type = Delete
appender.audit_rolling.strategy.action.basepath = ${sys:es.logs.base_path}
appender.audit_rolling.strategy.action.condition.type = IfLastModified

#Files will delete when the LastModified timestamp is 30 minutes old, can also be set to D for Days
appender.audit_rolling.strategy.action.condition.age = 1m
#appender.audit_rolling.strategy.action.PathConditions.type = IfFileName
#appender.audit_rolling.strategy.action.PathConditions.type = poc_audit-%d{yyyy-MM-dd}-%i.json.gz
appender.rolling.strategy.action.PathConditions.type = IfFileName
#appender.rolling.strategy.action.PathConditions.glob = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_audit-%d{yyyy-MM-dd}-%i.json.gz
appender.rolling.strategy.action.PathConditions.glob = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_audit-%d{yyyy-MM-dd}-%i.json.gz
appender.rolling.strategy.action.condition.nested_condition.type = IfAccumulatedFileSize
appender.rolling.strategy.action.condition.nested_condition.exceeds = 1KB

```

I have tried giving multiple conditions but didn't worked.  
It is deleting all the compressed files. I just want to delete only audit files.

Kindly help,

Regards,  
Tahseen

---

<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:** [December 31, 2021, 12:33pm UTC](https://discuss.elastic.co/t/logstash-log4j2-properties-deleting-all-the-compressed-files/290896/2 "2021-12-31T12:33:31Z")

</div>

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