Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #11132]feat: Add a rolling deletion strategy to solve the hidden danger of unlimited number of log files #11189

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions client/src/main/resources/nacos-log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
-->

<Configuration status="WARN">
<Properties>
<Property name="userHome" value="${sys:user.home}"/>
<Property name="logPath" value="${sys:JM.LOG.PATH:-${userHome}}"/>
</Properties>
<Appenders>
<RollingFile name="CONFIG_LOG_FILE" fileName="${sys:JM.LOG.PATH}/nacos/config.log"
filePattern="${sys:JM.LOG.PATH}/nacos/config.log.%d{yyyy-MM-dd}.%i">
Expand All @@ -28,7 +32,12 @@
<SizeBasedTriggeringPolicy size="${sys:JM.LOG.FILE.SIZE:-10MB}"/>
</Policies>

<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}"/>
<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}">
<Delete basePath="${logPath}/nacos" maxDepth="1" testMode="${sys:JM.LOG.RETAIN.DURATION.OFF:-true}">
<IfFileName glob="config.log.*.*" />
<IfLastModified age="${sys:JM.LOG.RETAIN.DURATION:-P180D}" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>

<Async name="ASYNC_CONFIG" bufferSize="1024" blocking="false">
Expand All @@ -46,14 +55,20 @@
<SizeBasedTriggeringPolicy size="${sys:JM.LOG.FILE.SIZE:-10MB}"/>
</Policies>

<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}"/>
<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}">
<Delete basePath="${logPath}/nacos" maxDepth="1" testMode="${sys:JM.LOG.RETAIN.DURATION.OFF:-true}">
<IfFileName glob="naming.log.*.*" />
<IfLastModified age="${sys:JM.LOG.RETAIN.DURATION:-P180D}" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>

<Async name="ASYNC_NAMING" bufferSize="1024" blocking="false">
<AppenderRef ref="NAMING_LOG_FILE"/>
</Async>
</Appenders>

<Async name="ASYNC_NAMING" bufferSize="1024" blocking="false">
<AppenderRef ref="NAMING_LOG_FILE"/>
</Async>



<Loggers>
<Logger name="com.alibaba.nacos.client" level="${sys:com.alibaba.nacos.config.log.level:-info}"
additivity="false">
Expand Down