Commit 0d2cf649 by QIANGLU

Merge branch 'dev'

parents 49ec78fd 6ae58b47
......@@ -7,6 +7,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import com.ctrip.framework.apollo.spring.boot.ApolloAutoConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggingSystem;
......@@ -22,7 +23,7 @@ import java.util.Set;
*/
@Configuration
@ConditionalOnClass(ApolloAutoConfiguration.class)
public class MatrixLogListenerConfiguration {
public class MatrixLogListenerConfiguration implements InitializingBean {
private static final Logger logger = LoggerFactory.getLogger(MatrixLogListenerConfiguration.class);
......@@ -40,11 +41,10 @@ public class MatrixLogListenerConfiguration {
refreshLoggingLevels();
}
@PostConstruct
private void refreshLoggingLevels() {
Set<String> keyNames = config.getPropertyNames();
for (String key : keyNames) {
if (containsIgnoreCase(key, LOGGER_TAG)) {
if (StringUtils.startsWithIgnoreCase(key,LOGGER_TAG)) {
String strLevel = config.getProperty(key, "info");
LogLevel level = LogLevel.valueOf(strLevel.toUpperCase());
loggingSystem.setLogLevel(key.replace(LOGGER_TAG, ""), level);
......@@ -53,17 +53,9 @@ public class MatrixLogListenerConfiguration {
}
}
private static boolean containsIgnoreCase(String str, String searchStr) {
if (StringUtils.isEmpty(str) || StringUtils.isEmpty(searchStr)) {
return false;
}
int len = searchStr.length();
int max = str.length() - len;
for (int i = 0; i <= max; i++) {
if (str.regionMatches(true, i, searchStr, 0, len)) {
return true;
}
}
return false;
@Override
public void afterPropertiesSet() throws Exception {
refreshLoggingLevels();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment