优化日志

This commit is contained in:
Redkale
2022-12-23 20:56:27 +08:00
parent e44bfbe9f3
commit 48ba0edd2e
5 changed files with 24 additions and 12 deletions

View File

@@ -2,11 +2,9 @@
<application nodeid="10000" port="2020"> <application nodeid="10000" port="2020">
<resources> <properties load="config.properties">
<properties load="config.properties"> <property name="system.property.redkale.convert.protobuf.enumtostring" value="true"/>
<property name="system.property.redkale.convert.protobuf.enumtostring" value="true"/> </properties>
</properties>
</resources>
<server protocol="HTTP" port="5050"> <server protocol="HTTP" port="5050">
<request> <request>

View File

@@ -418,6 +418,7 @@ public final class Application {
+ "APP_JAVA = " + System.getProperty("java.runtime.name", System.getProperty("org.graalvm.nativeimage.kind") != null ? "Nativeimage" : "") + "APP_JAVA = " + System.getProperty("java.runtime.name", System.getProperty("org.graalvm.nativeimage.kind") != null ? "Nativeimage" : "")
+ " " + System.getProperty("java.runtime.version", System.getProperty("java.vendor.version", System.getProperty("java.vm.version"))) + "\r\n" //graalvm.nativeimage 模式下无 java.runtime.xxx 属性 + " " + System.getProperty("java.runtime.version", System.getProperty("java.vendor.version", System.getProperty("java.vm.version"))) + "\r\n" //graalvm.nativeimage 模式下无 java.runtime.xxx 属性
+ "APP_PID = " + ProcessHandle.current().pid() + "\r\n" + "APP_PID = " + ProcessHandle.current().pid() + "\r\n"
+ RESNAME_APP_NAME + " = " + this.name + "\r\n"
+ RESNAME_APP_NODEID + " = " + this.nodeid + "\r\n" + RESNAME_APP_NODEID + " = " + this.nodeid + "\r\n"
+ "APP_LOADER = " + this.classLoader.getClass().getSimpleName() + "\r\n" + "APP_LOADER = " + this.classLoader.getClass().getSimpleName() + "\r\n"
+ RESNAME_APP_ADDR + " = " + this.localAddress.getHostString() + ":" + this.localAddress.getPort() + "\r\n" + RESNAME_APP_ADDR + " = " + this.localAddress.getHostString() + ":" + this.localAddress.getPort() + "\r\n"
@@ -695,7 +696,9 @@ public final class Application {
InputStream in = df.toURL().openStream(); InputStream in = df.toURL().openStream();
ps.load(in); ps.load(in);
in.close(); in.close();
if (logger.isLoggable(Level.FINEST)) logger.log(Level.FINEST, "load properties(" + dfload + ") size = " + ps.size()); if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "load properties(" + dfload + ") size = " + ps.size());
}
ps.forEach((x, y) -> { //load中的配置项除了redkale.cachesource.和redkale.datasource.开头不应该有其他redkale.开头配置项 ps.forEach((x, y) -> { //load中的配置项除了redkale.cachesource.和redkale.datasource.开头不应该有其他redkale.开头配置项
if (!x.toString().startsWith("redkale.")) { if (!x.toString().startsWith("redkale.")) {
agentEnvs.put(x, y); agentEnvs.put(x, y);
@@ -728,8 +731,10 @@ public final class Application {
this.propertiesAgent.compile(propertiesConf); this.propertiesAgent.compile(propertiesConf);
} else { } else {
Map<String, Properties> propMap = this.propertiesAgent.init(this, propertiesConf); Map<String, Properties> propMap = this.propertiesAgent.init(this, propertiesConf);
int propCount = 0;
if (propMap != null) { if (propMap != null) {
for (Map.Entry<String, Properties> en : propMap.entrySet()) { for (Map.Entry<String, Properties> en : propMap.entrySet()) {
propCount += en.getValue().size();
if (en.getKey().startsWith("logging")) { if (en.getKey().startsWith("logging")) {
if (logProps != null) { if (logProps != null) {
logger.log(Level.WARNING, "skip repeat logging config properties(" + en.getKey() + ")"); logger.log(Level.WARNING, "skip repeat logging config properties(" + en.getKey() + ")");
@@ -741,8 +746,8 @@ public final class Application {
} }
} }
} }
logger.info("PropertiesAgent (type=" + this.propertiesAgent.getClass().getSimpleName() + ") load " + propCount + " data in " + (System.currentTimeMillis() - s) + " ms");
} }
logger.info("PropertiesAgent (type = " + this.propertiesAgent.getClass().getSimpleName() + ") init in " + (System.currentTimeMillis() - s) + " ms");
break; break;
} }
} }

View File

@@ -291,7 +291,7 @@ public class NodeHttpServer extends NodeServer {
} }
sb.append(" mapping to ").append(Arrays.toString(as.getValue())).append(LINE_SEPARATOR); sb.append(" mapping to ").append(Arrays.toString(as.getValue())).append(LINE_SEPARATOR);
} }
sb.append(localThreadName).append("All HttpServlets load cost ").append(System.currentTimeMillis() - starts).append(" ms").append(LINE_SEPARATOR); sb.append(localThreadName).append("All HttpServlets load in ").append(System.currentTimeMillis() - starts).append(" ms").append(LINE_SEPARATOR);
} }
if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString().trim()); if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString().trim());
} }

View File

@@ -544,9 +544,9 @@ public abstract class NodeServer {
for (String s : wlist) { for (String s : wlist) {
sb.append(s); sb.append(s);
} }
sb.append(localThreadName).append("All " + localServices.size() + " Services load cost ").append(System.currentTimeMillis() - starts).append(" ms"); sb.append(localThreadName).append("All " + localServices.size() + " Services load in ").append(System.currentTimeMillis() - starts).append(" ms");
} }
if (sb != null && preinite > 10) sb.append(localThreadName).append(ClusterAgent.class.getSimpleName()).append(" register ").append(preinite).append(" ms" + LINE_SEPARATOR); if (sb != null && preinite > 10) sb.append(localThreadName).append(ClusterAgent.class.getSimpleName()).append(" register in ").append(preinite).append(" ms" + LINE_SEPARATOR);
if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString()); if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString());
} }

View File

@@ -264,9 +264,18 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
public String toString() { public String toString() {
if (readConfProps == null) return getClass().getSimpleName() + "{}"; //compileMode模式下会为null if (readConfProps == null) return getClass().getSimpleName() + "{}"; //compileMode模式下会为null
if (readConfProps == writeConfProps) { if (readConfProps == writeConfProps) {
return getClass().getSimpleName() + "{url=" + readConfProps.getProperty(DATA_SOURCE_URL) + "}"; String url = readConfProps.getProperty(DATA_SOURCE_URL);
int pos = url.indexOf('?');
if (pos > 0) url = url.substring(0, pos) + "...";
return getClass().getSimpleName() + "{url=" + url + "}";
} else { } else {
return getClass().getSimpleName() + "{readurl=" + readConfProps.getProperty(DATA_SOURCE_URL) + ",writeurl=" + writeConfProps.getProperty(DATA_SOURCE_URL) + "}"; String readUrl = readConfProps.getProperty(DATA_SOURCE_URL);
int pos = readUrl.indexOf('?');
if (pos > 0) readUrl = readUrl.substring(0, pos) + "...";
String writeUrl = writeConfProps.getProperty(DATA_SOURCE_URL);
pos = writeUrl.indexOf('?');
if (pos > 0) writeUrl = writeUrl.substring(0, pos) + "...";
return getClass().getSimpleName() + "{readurl=" + readUrl + ",writeurl=" + writeUrl + "}";
} }
} }