Skip to content

Commit

Permalink
[ISSUE#3533] change cache dir with namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
realJackSun committed Sep 17, 2020
1 parent 700c90d commit 70e1135
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 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,16 @@ 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" + File.separator + "nacos");
} else {
loggingPath = loggingPath + File.separator + "nacos" + File.separator + "naming";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.alibaba.nacos.common.utils.ConvertUtils;
import com.alibaba.nacos.common.utils.StringUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -151,9 +152,12 @@ private void initLogName(Properties properties) {
}

private void initCacheDir() {
cacheDir = System.getProperty("com.alibaba.nacos.naming.cache.dir");
if (StringUtils.isEmpty(cacheDir)) {
cacheDir = System.getProperty("user.home") + "/nacos/naming/" + namespace;
cacheDir = System.getProperty("JM.SNAPSHOT.PATH");
if (StringUtils.isBlank(cacheDir)) {
cacheDir = System.getProperty("user.home") + File.separator + "nacos" + File.separator + "naming"
+ File.separator + namespace;
} else {
cacheDir = cacheDir + File.separator + "nacos" + File.separator + "naming" + File.separator + namespace;
}
}

Expand Down

0 comments on commit 70e1135

Please sign in to comment.