This commit is contained in:
nkorange 2019-07-15 15:47:02 +08:00
parent 5d019cb55e
commit 1711c3765f
23 changed files with 237 additions and 336 deletions

View File

@ -105,6 +105,8 @@ public class HostReactor {
return oldService;
}
boolean changed = false;
if (oldService != null) {
if (oldService.getLastRefTime() > serviceInfo.getLastRefTime()) {
NAMING_LOGGER.warn("out of date data received, old-t: " + oldService.getLastRefTime()
@ -157,16 +159,19 @@ public class HostReactor {
}
if (newHosts.size() > 0) {
changed = true;
NAMING_LOGGER.info("new ips(" + newHosts.size() + ") service: "
+ serviceInfo.getName() + " -> " + JSON.toJSONString(newHosts));
}
if (remvHosts.size() > 0) {
changed = true;
NAMING_LOGGER.info("removed ips(" + remvHosts.size() + ") service: "
+ serviceInfo.getName() + " -> " + JSON.toJSONString(remvHosts));
}
if (modHosts.size() > 0) {
changed = true;
NAMING_LOGGER.info("modified ips(" + modHosts.size() + ") service: "
+ serviceInfo.getName() + " -> " + JSON.toJSONString(modHosts));
}
@ -189,8 +194,10 @@ public class HostReactor {
MetricsMonitor.getServiceInfoMapSizeMonitor().set(serviceInfoMap.size());
NAMING_LOGGER.info("current ips:(" + serviceInfo.ipCount() + ") service: " + serviceInfo.getName() +
" -> " + JSON.toJSONString(serviceInfo.getHosts()));
if (changed) {
NAMING_LOGGER.info("current ips:(" + serviceInfo.ipCount() + ") service: " + serviceInfo.getName() +
" -> " + JSON.toJSONString(serviceInfo.getHosts()));
}
return serviceInfo;
}

View File

@ -22,6 +22,8 @@ import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.service.PersistService;
import com.alibaba.nacos.config.server.service.dump.DumpService;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.core.utils.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -63,4 +65,13 @@ public class OpsController {
return HttpServletResponse.SC_OK + "";
}
@RequestMapping(value = "/log", method = RequestMethod.PUT)
@ResponseBody
public String setLogLevel(HttpServletRequest request) {
String logName = WebUtils.required(request, "logName");
String logLevel = WebUtils.required(request, "logLevel");
LogUtil.setLogLevel(logName, logLevel);
return HttpServletResponse.SC_OK + "";
}
}

View File

@ -50,7 +50,7 @@ public class MemoryMonitor {
}
static final long DELAY_SECONDS = 10;
private static final long DELAY_SECONDS = 10;
@Scheduled(cron = "0 0 0 * * ?")
public void clear() {
@ -89,9 +89,7 @@ class NotifyTaskQueueMonitorTask implements Runnable {
@Override
public void run() {
int size = ((ScheduledThreadPoolExecutor)notifySingleService.getExecutor()).getQueue().size();
memoryLog.info("notifySingleServiceThreadPool-{}, toNotifyTaskSize={}",
new Object[] {((ScheduledThreadPoolExecutor)notifySingleService.getExecutor()).getClass().getName(),
size});
memoryLog.info("toNotifyTaskSize={}", size);
MetricsMonitor.getNotifyTaskMonitor().set(size);
}
}

View File

@ -302,7 +302,9 @@ public class BasicDataSourceServiceImpl implements DataSourceService {
@Override
public void run() {
defaultLog.info("check master db.");
if (defaultLog.isDebugEnabled()) {
defaultLog.debug("check master db.");
}
boolean isFound = false;
int index = -1;
@ -339,7 +341,9 @@ public class BasicDataSourceServiceImpl implements DataSourceService {
@Override
public void run() {
defaultLog.info("check db health.");
if (defaultLog.isDebugEnabled()) {
defaultLog.debug("check db health.");
}
String sql = "SELECT * FROM config_info_beta WHERE id = 1";
for (int i = 0; i < testJTList.size(); i++) {

View File

@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.config.server.utils;
import ch.qos.logback.classic.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,46 +29,74 @@ public class LogUtil {
/**
* 默认的日志
*/
static public final Logger defaultLog = LoggerFactory.getLogger("com.alibaba.nacos.config.startLog");
public static final Logger defaultLog = LoggerFactory.getLogger("com.alibaba.nacos.config.startLog");
/**
* 致命错误需要告警
*/
static public final Logger fatalLog = LoggerFactory
public static final Logger fatalLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.fatal");
/**
* 客户端GET方法获取数据的日志
*/
static public final Logger pullLog = LoggerFactory
public static final Logger pullLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.pullLog");
static public final Logger pullCheckLog = LoggerFactory
public static final Logger pullCheckLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.pullCheckLog");
/**
* 从DB dump数据的日志
*/
static public final Logger dumpLog = LoggerFactory
public static final Logger dumpLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.dumpLog");
static public final Logger memoryLog = LoggerFactory
public static final Logger memoryLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.monitorLog");
static public final Logger clientLog = LoggerFactory
public static final Logger clientLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.clientLog");
static public final Logger sdkLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.sdkLog");
static public final Logger traceLog = LoggerFactory
public static final Logger traceLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.traceLog");
static public final Logger aclLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.aclLog");
static public final Logger notifyLog = LoggerFactory
public static final Logger notifyLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.notifyLog");
static public final Logger appCollectorLog = LoggerFactory
.getLogger("com.alibaba.nacos.config.appCollectorLog");
public static void setLogLevel(String logName, String level) {
switch (logName) {
case "config-server":
((ch.qos.logback.classic.Logger) defaultLog).setLevel(Level.valueOf(level));
break;
case "config-fatal":
((ch.qos.logback.classic.Logger) fatalLog).setLevel(Level.valueOf(level));
break;
case "config-pull":
((ch.qos.logback.classic.Logger) pullLog).setLevel(Level.valueOf(level));
break;
case "config-pull-check":
((ch.qos.logback.classic.Logger) pullCheckLog).setLevel(Level.valueOf(level));
break;
case "config-dump":
((ch.qos.logback.classic.Logger) dumpLog).setLevel(Level.valueOf(level));
break;
case "config-memory":
((ch.qos.logback.classic.Logger) memoryLog).setLevel(Level.valueOf(level));
break;
case "config-client-request":
((ch.qos.logback.classic.Logger) clientLog).setLevel(Level.valueOf(level));
break;
case "config-trace":
((ch.qos.logback.classic.Logger) traceLog).setLevel(Level.valueOf(level));
break;
case "config-notify":
((ch.qos.logback.classic.Logger) notifyLog).setLevel(Level.valueOf(level));
break;
default:
break;
}
}
}

View File

@ -11,7 +11,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${nacos.home}/logs/cmdb-main.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -34,8 +34,8 @@
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-server.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>7</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -59,7 +59,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-raft.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -77,14 +77,14 @@
</appender>
<appender name="naming-ephemeral"
<appender name="naming-distro"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-ephemeral.log</file>
<file>${LOG_HOME}/naming-distro.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-ephemeral.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<fileNamePattern>${LOG_HOME}/naming-distro.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -94,11 +94,11 @@
</encoder>
</appender>
<appender name="async-naming-ephemeral" class="ch.qos.logback.classic.AsyncAppender">
<appender name="async-naming-distro" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1024</queueSize>
<neverBlock>true</neverBlock>
<appender-ref ref="naming-ephemeral"/>
<appender-ref ref="naming-distro"/>
</appender>
<appender name="naming-event"
@ -108,7 +108,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-event.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -132,7 +132,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-push.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -148,7 +148,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-rt.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -165,7 +165,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-performance.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -175,109 +175,6 @@
</encoder>
</appender>
<appender name="naming-router"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-router.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-router.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date|%msg%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="naming-cache"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-cache.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-cache.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date|%msg%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="naming-device"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-device.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-device.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date|%msg%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="naming-tag"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-tag.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-tag.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date %level %msg%n%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="naming-tenant"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-tenant.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-tenant.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date %level %msg%n%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="naming-debug"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/naming-debug.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/naming-debug.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date %level %msg%n%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--config module logback config-->
<appender name="dumpFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
@ -286,7 +183,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-dump.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -302,7 +199,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-pull.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>128MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -318,7 +215,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-fatal.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>128MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -334,7 +231,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-memory.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>128MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -350,7 +247,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-pull-check.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -360,23 +257,6 @@
</encoder>
</appender>
<appender name="aclLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/config-acl.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-acl.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>512MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date %level %msg%n%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="clientLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/config-client-request.log</file>
@ -384,7 +264,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-client-request.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -394,23 +274,6 @@
</encoder>
</appender>
<appender name="sdkLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/config-sdk-request.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-sdk-request.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date|%msg%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="traceLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/config-trace.log</file>
@ -418,7 +281,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-trace.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -435,7 +298,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-notify.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>1GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>3GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -445,23 +308,6 @@
</encoder>
</appender>
<appender name="appCollectorLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/config-app.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-app.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<totalSizeCap>128MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<Pattern>%date %level %msg%n%n</Pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="startLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/config-server.log</file>
@ -469,7 +315,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/config-server.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>512MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -486,7 +332,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/nacos.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>512MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -503,7 +349,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/nacos-address.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxFileSize>2GB</maxFileSize>
<MaxHistory>15</MaxHistory>
<MaxHistory>7</MaxHistory>
<totalSizeCap>7GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
@ -531,9 +377,9 @@
<level value="INFO"/>
<appender-ref ref="async-naming-raft"/>
</logger>
<logger name="com.alibaba.nacos.naming.ephemeral" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="async-naming-ephemeral"/>
<logger name="com.alibaba.nacos.naming.distro" additivity="false">
<level value="INFO"/>
<appender-ref ref="async-naming-distro"/>
</logger>
<logger name="com.alibaba.nacos.naming.event" additivity="false">
<level value="INFO"/>
@ -551,22 +397,6 @@
<level value="INFO"/>
<appender-ref ref="naming-performance"/>
</logger>
<logger name="com.alibaba.nacos.naming.router" additivity="false">
<level value="INFO"/>
<appender-ref ref="naming-router"/>
</logger>
<logger name="com.alibaba.nacos.naming.cache" additivity="false">
<level value="INFO"/>
<appender-ref ref="naming-cache"/>
</logger>
<logger name="com.alibaba.nacos.naming.tenant" additivity="false">
<level value="INFO"/>
<appender-ref ref="naming-tenant"/>
</logger>
<logger name="com.alibaba.nacos.naming.debug" additivity="false">
<level value="INFO"/>
<appender-ref ref="naming-debug"/>
</logger>
<logger name="com.alibaba.nacos.config.dumpLog" additivity="false">
<level value="INFO"/>
@ -589,21 +419,11 @@
<appender-ref ref="memoryFile"/>
</logger>
<logger name="com.alibaba.nacos.config.aclLog" additivity="false">
<level value="INFO"/>
<appender-ref ref="aclLog"/>
</logger>
<logger name="com.alibaba.nacos.config.clientLog" additivity="false">
<level value="info"/>
<appender-ref ref="clientLog"/>
</logger>
<logger name="com.alibaba.nacos.config.sdkLog" additivity="false">
<level value="INFO"/>
<appender-ref ref="sdkLog"/>
</logger>
<logger name="com.alibaba.nacos.config.notifyLog" additivity="false">
<level value="INFO"/>
<appender-ref ref="notifyLog"/>
@ -614,11 +434,6 @@
<appender-ref ref="traceLog"/>
</logger>
<logger name="com.alibaba.nacos.config.appCollectorLog" additivity="false">
<level value="INFO"/>
<appender-ref ref="appCollectorLog"/>
</logger>
<logger name="com.alibaba.nacos.config.startLog" additivity="false">
<level value="INFO"/>
<appender-ref ref="startLog"/>

View File

@ -93,15 +93,15 @@ public class ServerListManager {
Loggers.SRV_LOG.warn("failed to get config: " + CLUSTER_CONF_FILE_PATH, e);
}
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("SERVER-LIST from cluster.conf: {}", result);
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("SERVER-LIST from cluster.conf: {}", result);
}
//use system env
if (CollectionUtils.isEmpty(serverList)) {
serverList = SystemUtils.getIPsBySystemEnv(UtilsAndCommons.SELF_SERVICE_CLUSTER_ENV);
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("SERVER-LIST from system variable: {}", result);
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("SERVER-LIST from system variable: {}", result);
}
}

View File

@ -75,8 +75,8 @@ public class DataSyncer {
String key = iterator.next();
if (StringUtils.isNotBlank(taskMap.putIfAbsent(buildKey(key, task.getTargetServer()), key))) {
// associated key already exist:
if (Loggers.EPHEMERAL.isDebugEnabled()) {
Loggers.EPHEMERAL.debug("sync already in process, key: {}", key);
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("sync already in process, key: {}", key);
}
iterator.remove();
}
@ -100,8 +100,8 @@ public class DataSyncer {
List<String> keys = task.getKeys();
if (Loggers.EPHEMERAL.isDebugEnabled()) {
Loggers.EPHEMERAL.debug("sync keys: {}", keys);
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("sync keys: {}", keys);
}
Map<String, Datum> datumMap = dataStore.batchGet(keys);
@ -133,7 +133,7 @@ public class DataSyncer {
}
} catch (Exception e) {
Loggers.EPHEMERAL.error("sync data failed.", e);
Loggers.DISTRO.error("sync data failed.", e);
}
}
}, delay);
@ -164,8 +164,8 @@ public class DataSyncer {
try {
if (Loggers.EPHEMERAL.isDebugEnabled()) {
Loggers.EPHEMERAL.debug("server list is: {}", getServers());
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("server list is: {}", getServers());
}
// send local timestamps to other servers:
@ -182,8 +182,8 @@ public class DataSyncer {
return;
}
if (Loggers.EPHEMERAL.isDebugEnabled()) {
Loggers.EPHEMERAL.debug("sync checksums: {}", keyChecksums);
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("sync checksums: {}", keyChecksums);
}
for (Server member : getServers()) {
@ -193,7 +193,7 @@ public class DataSyncer {
NamingProxy.syncCheckSums(keyChecksums, member.getKey());
}
} catch (Exception e) {
Loggers.EPHEMERAL.error("timed sync task failed.", e);
Loggers.DISTRO.error("timed sync task failed.", e);
}
}
}

View File

@ -111,7 +111,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
try {
load();
} catch (Exception e) {
Loggers.EPHEMERAL.error("load data failed.", e);
Loggers.DISTRO.error("load data failed.", e);
}
}
});
@ -127,15 +127,15 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
// size = 1 means only myself in the list, we need at least one another server alive:
while (serverListManager.getHealthyServers().size() <= 1) {
Thread.sleep(1000L);
Loggers.EPHEMERAL.info("waiting server list init...");
Loggers.DISTRO.info("waiting server list init...");
}
for (Server server : serverListManager.getHealthyServers()) {
if (NetUtils.localServer().equals(server.getKey())) {
continue;
}
if (Loggers.EPHEMERAL.isDebugEnabled()) {
Loggers.EPHEMERAL.debug("sync from " + server);
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("sync from " + server);
}
// try sync data from remote server:
if (syncAllDataFromRemote(server)) {
@ -195,7 +195,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
if (syncChecksumTasks.containsKey(server)) {
// Already in process of this server:
Loggers.EPHEMERAL.warn("sync checksum task already in process with {}", server);
Loggers.DISTRO.warn("sync checksum task already in process with {}", server);
return;
}
@ -208,7 +208,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
for (Map.Entry<String, String> entry : checksumMap.entrySet()) {
if (distroMapper.responsible(KeyBuilder.getServiceName(entry.getKey()))) {
// this key should not be sent from remote server:
Loggers.EPHEMERAL.error("receive responsible key timestamp of " + entry.getKey() + " from " + server);
Loggers.DISTRO.error("receive responsible key timestamp of " + entry.getKey() + " from " + server);
// abort the procedure:
return;
}
@ -230,7 +230,9 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
}
}
Loggers.EPHEMERAL.info("to remove keys: {}, to update keys: {}, source: {}", toRemoveKeys, toUpdateKeys, server);
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.info("to remove keys: {}, to update keys: {}, source: {}", toRemoveKeys, toUpdateKeys, server);
}
for (String key : toRemoveKeys) {
onRemove(key);
@ -244,7 +246,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
byte[] result = NamingProxy.getData(toUpdateKeys, server);
processData(result);
} catch (Exception e) {
Loggers.EPHEMERAL.error("get data from " + server + " failed!", e);
Loggers.DISTRO.error("get data from " + server + " failed!", e);
}
} finally {
// Remove this 'in process' flag:
@ -260,7 +262,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
processData(data);
return true;
} catch (Exception e) {
Loggers.EPHEMERAL.error("sync full data from " + server + " failed!", e);
Loggers.DISTRO.error("sync full data from " + server + " failed!", e);
return false;
}
}
@ -278,7 +280,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
// pretty sure the service not exist:
if (switchDomain.isDefaultInstanceEphemeral()) {
// create empty service
Loggers.EPHEMERAL.info("creating service {}", entry.getKey());
Loggers.DISTRO.info("creating service {}", entry.getKey());
Service service = new Service();
String serviceName = KeyBuilder.getServiceName(entry.getKey());
String namespaceId = KeyBuilder.getNamespace(entry.getKey());
@ -298,7 +300,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
if (!listeners.containsKey(entry.getKey())) {
// Should not happen:
Loggers.EPHEMERAL.warn("listener of {} not found.", entry.getKey());
Loggers.DISTRO.warn("listener of {} not found.", entry.getKey());
continue;
}
@ -307,7 +309,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
listener.onChange(entry.getKey(), entry.getValue().value);
}
} catch (Exception e) {
Loggers.EPHEMERAL.error("[NACOS-DISTRO] error while execute listener of key: {}", entry.getKey(), e);
Loggers.DISTRO.error("[NACOS-DISTRO] error while execute listener of key: {}", entry.getKey(), e);
continue;
}
@ -370,7 +372,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
@Override
public void run() {
Loggers.EPHEMERAL.info("distro notifier started");
Loggers.DISTRO.info("distro notifier started");
while (true) {
try {
@ -407,16 +409,16 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
continue;
}
} catch (Throwable e) {
Loggers.EPHEMERAL.error("[NACOS-DISTRO] error while notifying listener of key: {}", datumKey, e);
Loggers.DISTRO.error("[NACOS-DISTRO] error while notifying listener of key: {}", datumKey, e);
}
}
if (Loggers.EPHEMERAL.isDebugEnabled()) {
Loggers.EPHEMERAL.debug("[NACOS-DISTRO] datum change notified, key: {}, listener count: {}, action: {}",
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("[NACOS-DISTRO] datum change notified, key: {}, listener count: {}, action: {}",
datumKey, count, action.name());
}
} catch (Throwable e) {
Loggers.EPHEMERAL.error("[NACOS-DISTRO] Error while handling notifying task", e);
Loggers.DISTRO.error("[NACOS-DISTRO] Error while handling notifying task", e);
}
}
}

View File

@ -94,8 +94,8 @@ public class TaskDispatcher {
String key = queue.poll(partitionConfig.getTaskDispatchPeriod(),
TimeUnit.MILLISECONDS);
if (Loggers.EPHEMERAL.isDebugEnabled() && StringUtils.isNotBlank(key)) {
Loggers.EPHEMERAL.debug("got key: {}", key);
if (Loggers.DISTRO.isDebugEnabled() && StringUtils.isNotBlank(key)) {
Loggers.DISTRO.debug("got key: {}", key);
}
if (dataSyncer.getServers() == null || dataSyncer.getServers().isEmpty()) {
@ -124,8 +124,8 @@ public class TaskDispatcher {
syncTask.setKeys(keys);
syncTask.setTargetServer(member.getKey());
if (Loggers.EPHEMERAL.isDebugEnabled() && StringUtils.isNotBlank(key)) {
Loggers.EPHEMERAL.debug("add sync task: {}", JSON.toJSONString(syncTask));
if (Loggers.DISTRO.isDebugEnabled() && StringUtils.isNotBlank(key)) {
Loggers.DISTRO.debug("add sync task: {}", JSON.toJSONString(syncTask));
}
dataSyncer.submit(syncTask, 0);
@ -135,7 +135,7 @@ public class TaskDispatcher {
}
} catch (Exception e) {
Loggers.EPHEMERAL.error("dispatch sync task failed.", e);
Loggers.DISTRO.error("dispatch sync task failed.", e);
}
}
}

View File

@ -485,7 +485,9 @@ public class RaftCore {
return;
}
Loggers.RAFT.info("[RAFT] send beat with {} keys.", datums.size());
if (Loggers.RAFT.isDebugEnabled()) {
Loggers.RAFT.debug("[RAFT] send beat with {} keys.", datums.size());
}
local.resetLeaderDue();
@ -513,8 +515,6 @@ public class RaftCore {
array.add(element);
}
} else {
Loggers.RAFT.info("[RAFT] send beat only.");
}
packet.put("datums", array);
@ -531,13 +531,18 @@ public class RaftCore {
byte[] compressedBytes = out.toByteArray();
String compressedContent = new String(compressedBytes, StandardCharsets.UTF_8);
Loggers.RAFT.info("raw beat data size: {}, size of compressed data: {}",
content.length(), compressedContent.length());
if (Loggers.RAFT.isDebugEnabled()) {
Loggers.RAFT.debug("raw beat data size: {}, size of compressed data: {}",
content.length(), compressedContent.length());
}
for (final String server : peers.allServersWithoutMySelf()) {
try {
final String url = buildURL(server, API_BEAT);
Loggers.RAFT.info("send beat to server " + server);
if (Loggers.RAFT.isDebugEnabled()) {
Loggers.RAFT.debug("send beat to server " + server);
}
HttpClient.asyncHttpPostLarge(url, null, compressedBytes, new AsyncCompletionHandler<Integer>() {
@Override
public Integer onCompleted(Response response) throws Exception {
@ -549,7 +554,9 @@ public class RaftCore {
}
peers.update(JSON.parseObject(response.getResponseBody(), RaftPeer.class));
Loggers.RAFT.info("receive beat response from: {}", url);
if (Loggers.RAFT.isDebugEnabled()) {
Loggers.RAFT.debug("receive beat response from: {}", url);
}
return 0;
}
@ -615,8 +622,10 @@ public class RaftCore {
List<String> batch = new ArrayList<>();
if (!switchDomain.isSendBeatOnly()) {
int processedCount = 0;
Loggers.RAFT.info("[RAFT] received beat with {} keys, RaftCore.datums' size is {}, remote server: {}, term: {}, local term: {}",
beatDatums.size(), datums.size(), remote.ip, remote.term, local.term);
if (Loggers.RAFT.isDebugEnabled()) {
Loggers.RAFT.debug("[RAFT] received beat with {} keys, RaftCore.datums' size is {}, remote server: {}, term: {}, local term: {}",
beatDatums.size(), datums.size(), remote.ip, remote.term, local.term);
}
for (Object object : beatDatums) {
processedCount = processedCount + 1;

View File

@ -74,7 +74,7 @@ public class DistroController {
String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
if (StringUtils.isBlank(entity)) {
Loggers.EPHEMERAL.error("[onSync] receive empty entity!");
Loggers.DISTRO.error("[onSync] receive empty entity!");
throw new NacosException(NacosException.INVALID_PARAM, "receive empty entity!");
}

View File

@ -234,8 +234,8 @@ public class InstanceController {
String clusterName = clientBeat.getCluster();
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("[CLIENT-BEAT] full arguments: beat: {}, serviceName: {}", clientBeat, serviceName);
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("[CLIENT-BEAT] full arguments: beat: {}, serviceName: {}", clientBeat, serviceName);
}
Instance instance = serviceManager.getInstance(namespaceId, serviceName, clientBeat.getCluster(), clientBeat.getIp(),
@ -372,8 +372,8 @@ public class InstanceController {
Service service = serviceManager.getService(namespaceId, serviceName);
if (service == null) {
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("no instance to serve for service: " + serviceName);
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("no instance to serve for service: " + serviceName);
}
result.put("name", serviceName);
result.put("hosts", new JSONArray());
@ -412,8 +412,8 @@ public class InstanceController {
if (CollectionUtils.isEmpty(srvedIPs)) {
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("no instance to serve for service: " + serviceName);
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("no instance to serve for service: " + serviceName);
}
if (clientInfo.type == ClientInfo.ClientType.JAVA &&

View File

@ -29,10 +29,7 @@ import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet;
import com.alibaba.nacos.naming.core.DistroMapper;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.core.ServiceManager;
import com.alibaba.nacos.naming.misc.SwitchDomain;
import com.alibaba.nacos.naming.misc.SwitchEntry;
import com.alibaba.nacos.naming.misc.SwitchManager;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.alibaba.nacos.naming.misc.*;
import com.alibaba.nacos.naming.pojo.ClusterStateView;
import com.alibaba.nacos.naming.push.PushService;
import com.alibaba.nacos.naming.web.NeedAuth;
@ -55,7 +52,7 @@ import java.util.List;
* @author nkorange
*/
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + "/operator")
@RequestMapping({UtilsAndCommons.NACOS_NAMING_CONTEXT + "/operator", UtilsAndCommons.NACOS_NAMING_CONTEXT + "/ops"})
public class OperatorController {
@Autowired
@ -224,6 +221,14 @@ public class OperatorController {
return "ok";
}
@RequestMapping(value = "/log", method = RequestMethod.PUT)
public String setLogLevel(HttpServletRequest request) {
String logName = WebUtils.required(request, "logName");
String logLevel = WebUtils.required(request, "logLevel");
Loggers.setLogLevel(logName, logLevel);
return "ok";
}
@RequestMapping(value = "/cluster/states", method = RequestMethod.GET)
public Object listStates(HttpServletRequest request) {

View File

@ -283,27 +283,35 @@ public class ServiceManager implements RecordListener<Service> {
return;
}
boolean changed = false;
List<Instance> instances = service.allIPs();
for (Instance instance : instances) {
Boolean valid = Boolean.parseBoolean(ipsMap.get(instance.toIPAddr()));
boolean valid = Boolean.parseBoolean(ipsMap.get(instance.toIPAddr()));
if (valid != instance.isHealthy()) {
changed = true;
instance.setHealthy(valid);
Loggers.EVT_LOG.info("{} {SYNC} IP-{} : {}@{}",
Loggers.EVT_LOG.info("{} {SYNC} IP-{} : {}@{}{}",
serviceName, (instance.isHealthy() ? "ENABLED" : "DISABLED"),
instance.getIp(), instance.getPort(), instance.getClusterName());
}
}
pushService.serviceChanged(service);
if (changed) {
pushService.serviceChanged(service);
}
StringBuilder stringBuilder = new StringBuilder();
List<Instance> allIps = service.allIPs();
for (Instance instance : allIps) {
stringBuilder.append(instance.toIPAddr()).append("_").append(instance.isHealthy()).append(",");
}
Loggers.EVT_LOG.info("[IP-UPDATED] namespace: {}, service: {}, ips: {}",
service.getNamespaceId(), service.getName(), stringBuilder.toString());
if (changed && Loggers.EVT_LOG.isDebugEnabled()) {
Loggers.EVT_LOG.debug("[HEALTH-STATUS-UPDATED] namespace: {}, service: {}, ips: {}",
service.getNamespaceId(), service.getName(), stringBuilder.toString());
}
}

View File

@ -88,8 +88,8 @@ public class HealthCheckCommon {
}
Map<String, String> params = new HashMap<>(10);
params.put("result", JSON.toJSONString(list));
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("[HEALTH-SYNC] server: {}, healthCheckResults: {}",
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("[HEALTH-SYNC] server: {}, healthCheckResults: {}",
server, JSON.toJSONString(list));
}

View File

@ -94,10 +94,13 @@ public class HealthCheckTask implements Runnable {
this.setCheckRTLastLast(this.getCheckRTLast());
Cluster cluster = this.getCluster();
Loggers.CHECK_RT.info("{}:{}@{}->normalized: {}, worst: {}, best: {}, last: {}, diff: {}",
cluster.getService().getName(), cluster.getName(), cluster.getHealthChecker().getType(),
this.getCheckRTNormalized(), this.getCheckRTWorst(), this.getCheckRTBest(),
this.getCheckRTLast(), diff);
if (Loggers.CHECK_RT.isDebugEnabled()) {
Loggers.CHECK_RT.debug("{}:{}@{}->normalized: {}, worst: {}, best: {}, last: {}, diff: {}",
cluster.getService().getName(), cluster.getName(), cluster.getHealthChecker().getType(),
this.getCheckRTNormalized(), this.getCheckRTWorst(), this.getCheckRTBest(),
this.getCheckRTLast(), diff);
}
}
}
}

View File

@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.naming.misc;
import ch.qos.logback.classic.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,9 +34,37 @@ public class Loggers {
public static final Logger RAFT = LoggerFactory.getLogger("com.alibaba.nacos.naming.raft");
public static final Logger EPHEMERAL = LoggerFactory.getLogger("com.alibaba.nacos.naming.ephemeral");
public static final Logger DISTRO = LoggerFactory.getLogger("com.alibaba.nacos.naming.distro");
public static final Logger PERFORMANCE_LOG = LoggerFactory.getLogger("com.alibaba.nacos.naming.performance");
public static final Logger DEBUG_LOG = LoggerFactory.getLogger("com.alibaba.nacos.naming.debug");
public static void setLogLevel(String logName, String level) {
switch (logName) {
case "naming-push":
((ch.qos.logback.classic.Logger) PUSH).setLevel(Level.valueOf(level));
break;
case "naming-rt":
((ch.qos.logback.classic.Logger) CHECK_RT).setLevel(Level.valueOf(level));
break;
case "naming-server":
((ch.qos.logback.classic.Logger) SRV_LOG).setLevel(Level.valueOf(level));
break;
case "naming-event":
((ch.qos.logback.classic.Logger) EVT_LOG).setLevel(Level.valueOf(level));
break;
case "naming-raft":
((ch.qos.logback.classic.Logger) RAFT).setLevel(Level.valueOf(level));
break;
case "naming-distro":
((ch.qos.logback.classic.Logger) DISTRO).setLevel(Level.valueOf(level));
break;
case "naming-performance":
((ch.qos.logback.classic.Logger) PERFORMANCE_LOG).setLevel(Level.valueOf(level));
break;
default:
break;
}
}
}

View File

@ -54,7 +54,7 @@ public class NamingProxy {
@Override
public Object onCompleted(Response response) throws Exception {
if (HttpURLConnection.HTTP_OK != response.getStatusCode()) {
Loggers.EPHEMERAL.error("failed to req API: {}, code: {}, msg: {}",
Loggers.DISTRO.error("failed to req API: {}, code: {}, msg: {}",
"http://" + server + RunningConfig.getContextPath() +
UtilsAndCommons.NACOS_NAMING_CONTEXT + TIMESTAMP_SYNC_URL,
response.getStatusCode(), response.getResponseBody());
@ -64,13 +64,13 @@ public class NamingProxy {
@Override
public void onThrowable(Throwable t) {
Loggers.EPHEMERAL.error("failed to req API:" + "http://" + server
Loggers.DISTRO.error("failed to req API:" + "http://" + server
+ RunningConfig.getContextPath()
+ UtilsAndCommons.NACOS_NAMING_CONTEXT + TIMESTAMP_SYNC_URL, t);
}
});
} catch (Exception e) {
Loggers.EPHEMERAL.warn("NamingProxy", e);
Loggers.DISTRO.warn("NamingProxy", e);
}
}

View File

@ -79,7 +79,9 @@ public class ServiceStatusSynchronizer implements Synchronizer {
String result;
try {
Loggers.SRV_LOG.info("[STATUS-SYNCHRONIZE] sync service status from: {}, service: {}", serverIP, key);
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("[STATUS-SYNCHRONIZE] sync service status from: {}, service: {}", serverIP, key);
}
result = NamingProxy.reqAPI(RunningConfig.getContextPath()
+ UtilsAndCommons.NACOS_NAMING_CONTEXT + "/instance/" + "statuses", params, serverIP);
} catch (Exception e) {

View File

@ -19,7 +19,6 @@ import com.alibaba.nacos.naming.consistency.persistent.raft.RaftCore;
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeer;
import com.alibaba.nacos.naming.core.ServiceManager;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.SwitchDomain;
import com.alibaba.nacos.naming.push.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@ -42,9 +41,6 @@ public class PerformanceLoggerThread {
@Autowired
private ServiceManager serviceManager;
@Autowired
private SwitchDomain switchDomain;
@Autowired
private PushService pushService;
@ -62,34 +58,15 @@ public class PerformanceLoggerThread {
});
private static final long PERIOD = 5 * 60;
private static final long HEALTH_CHECK_PERIOD = 5 * 60;
@PostConstruct
public void init() {
start();
}
private void freshHealthCheckSwitch() {
Loggers.SRV_LOG.info("[HEALTH-CHECK] health check is {}", switchDomain.isHealthCheckEnabled());
}
class HealthCheckSwitchTask implements Runnable {
@Override
public void run() {
try {
freshHealthCheckSwitch();
} catch (Exception ignore) {
}
}
}
private void start() {
PerformanceLogTask task = new PerformanceLogTask();
executor.scheduleWithFixedDelay(task, 30, PERIOD, TimeUnit.SECONDS);
executor.scheduleWithFixedDelay(new HealthCheckSwitchTask(), 30, HEALTH_CHECK_PERIOD, TimeUnit.SECONDS);
}
@Scheduled(cron = "0 0 0 * * ?")

View File

@ -275,7 +275,9 @@ public class PushService implements ApplicationContextAware, ApplicationListener
size += clientConcurrentMap.size();
}
Loggers.PUSH.info("[NACOS-PUSH] clientMap size: {}", size);
if (Loggers.PUSH.isDebugEnabled()) {
Loggers.PUSH.debug("[NACOS-PUSH] clientMap size: {}", size);
}
}