Skip to content

Commit

Permalink
[ISSUE#3533] change cache dir with namespace -- part 2: unify the log…
Browse files Browse the repository at this point in the history
… dir (#3882)
  • Loading branch information
realJackSun authored Oct 12, 2020
1 parent 17be398 commit 714b967
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.alibaba.nacos.common.utils.ConvertUtils;
import com.alibaba.nacos.common.utils.StringUtils;

import java.io.File;

/**
* Abstract nacos logging.
*
Expand All @@ -31,13 +33,13 @@ public abstract class AbstractNacosLogging {

private static final String NACOS_LOGGING_DEFAULT_CONFIG_ENABLED_PROPERTY = "nacos.logging.default.config.enabled";

private static final String NACOS_LOGGING_PATH_PROPERTY = "nacos.logging.path";
private static final String NACOS_LOGGING_PATH_PROPERTY = "JM.LOG.PATH";

static {
String loggingPath = System.getProperty(NACOS_LOGGING_PATH_PROPERTY);
if (StringUtils.isBlank(loggingPath)) {
String userHome = System.getProperty("user.home");
System.setProperty(NACOS_LOGGING_PATH_PROPERTY, userHome + "/logs/nacos");
System.setProperty(NACOS_LOGGING_PATH_PROPERTY, userHome + File.separator + "logs");
}
}

Expand Down
8 changes: 4 additions & 4 deletions client/src/main/resources/nacos-log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

<Configuration status="WARN">
<Appenders>
<RollingFile name="CONFIG_LOG_FILE" fileName="${sys:nacos.logging.path}/config.log"
filePattern="${sys:nacos.logging.path}/config.log.%d{yyyy-MM-dd}.%i">
<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">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%-5t:%c{2}] %m%n</Pattern>
</PatternLayout>
Expand All @@ -31,8 +31,8 @@
<DefaultRolloverStrategy max="${sys:JM.LOG.RETAIN.COUNT:-7}"/>
</RollingFile>

<RollingFile name="NAMING_LOG_FILE" fileName="${sys:nacos.logging.path}/naming.log"
filePattern="${sys:nacos.logging.path}/naming.log.%d{yyyy-MM-dd}.%i">
<RollingFile name="NAMING_LOG_FILE" fileName="${sys:JM.LOG.PATH}/nacos/naming.log"
filePattern="${sys:JM.LOG.PATH}/nacos/naming.log.%d{yyyy-MM-dd}.%i">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [%-5t:%c{2}] %m%n</Pattern>
</PatternLayout>
Expand Down
8 changes: 4 additions & 4 deletions client/src/main/resources/nacos-logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<contextName>nacos</contextName>

<appender name="CONFIG_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${nacos.logging.path}/config.log</file>
<file>${JM.LOG.PATH}/nacos/config.log</file>

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${nacos.logging.path}/config.log.%i</fileNamePattern>
<fileNamePattern>${JM.LOG.PATH}/nacos/config.log.%i</fileNamePattern>
<maxIndex>${JM.LOG.RETAIN.COUNT:-7}</maxIndex>
</rollingPolicy>

Expand All @@ -36,10 +36,10 @@
</appender>

<appender name="NAMING_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${nacos.logging.path}/naming.log</file>
<file>${JM.LOG.PATH}/nacos/naming.log</file>

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${nacos.logging.path}/naming.log.%i</fileNamePattern>
<fileNamePattern>${JM.LOG.PATH}/nacos/naming.log.%i</fileNamePattern>
<maxIndex>${JM.LOG.RETAIN.COUNT:-7}</maxIndex>
</rollingPolicy>

Expand Down

0 comments on commit 714b967

Please sign in to comment.