Delete Elasticsearch logs

Hi guys,

I would like to delete elasticsearch logs placed in /var/log/elasticsearch older then 7 days.
I can not find any parameter in log4j2.properties from ELastic official site.
Do you have any idea about it or should I use logrotator of linux.

Thanks,

Hi @hzarrabi - I have not tried this but I believe you should be able to able to configure a Delete action that uses a IfLastModified condition.

Hi @ropc,

Thank you so much. The solution you give, is it applicable to the latest 7.x versions ?

The link IfLastModified condition, shows the following lines which relate to DELETING the log files. But, I don't see them in the log4j2.properties file of recent version 7.x.

appender.rolling.strategy.action.condition.type = IfFileName
appender.rolling.strategy.action.condition.glob = mylog-*.log
appender.rolling.strategy.action.PathConditions.type = IfAny
appender.rolling.strategy.action.PathConditions.nestedConditions.type = IfLastModified
appender.rolling.strategy.action.PathConditions.nestedConditions.age = 90D

Best Regards

Hi @hzarrabi - yes it is applicable to version 7.x. You will need to amend the log4j2.properties configuration file accordingly.

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