Skip to content

Commit

Permalink
fix 修复oshi日志打印问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tzfun committed Dec 29, 2023
1 parent 2ad6f75 commit ce67367
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private static void notifyListener(int listenerPort, String message) {

private static void bootServer(Instrumentation inst, List<URL> needPreLoad, String agentArgs) throws InterruptedException {
// 启动日志打印代理消费线程
// runLoggerConsumer();
runLoggerConsumer();
running = true;
bindThread = new Thread(() -> {
int listenerPort = findListenerPortFromArgs(agentArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ protected void handleException(ChannelHandlerContext ctx, JvmmRequest req, Throw
.setType(req.getType())
.setContextId(req.getContextId());
if (e instanceof IllegalArgumentException) {
logger().error("Handle jvmm request failed: " + e.getMessage(), e);
logger().warn("Handle jvmm request failed: " + e.getMessage(), logger().isDebugEnabled() ? e : null);
response.setStatus(RpcStatus.JVMM_STATUS_ILLEGAL_ARGUMENTS).setMessage(e.getMessage());
} else {
logger().error(e.getMessage(), e);
Expand Down
8 changes: 5 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ dependencies {
compile(project(':common'))
compileOnly(files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()))
compile "org.benf:cfr:${cfrVersion}"
compile "com.github.oshi:oshi-core:${oshiVersion}"
compile("com.github.oshi:oshi-core:${oshiVersion}") {
exclude group: 'org.slf4j'
}
}

jar {
Expand Down Expand Up @@ -48,7 +50,7 @@ artifacts {
archives sourcesJar, javadocJar
}

if(env == 'publish') {
if (env == 'publish') {
uploadArchives {
repositories {
mavenDeployer {
Expand Down Expand Up @@ -95,4 +97,4 @@ if(env == 'publish') {
signing {
sign configurations.archives
}
}
}
4 changes: 2 additions & 2 deletions logger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = rootProject.version

dependencies {
compile(project(":common"))
compileOnly "org.slf4j:slf4j-api:1.7.30"
compile "org.slf4j:slf4j-api:1.7.36"
}

jar {
Expand Down Expand Up @@ -91,4 +91,4 @@ if(env == 'publish') {
signing {
sign configurations.archives
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ public void updatePrinters() {
String ps = config.getPrinters();
for (String p : ps.split(",")) {
if ("std".equalsIgnoreCase(p.trim())) {
System.out.println("Use std printer");
printers.add(new StdPrinter());
} else if ("file".equalsIgnoreCase(p.trim())) {
System.out.println("Use file printer");
printers.add(new FilePrinter(config));
} else if ("agentProxy".equalsIgnoreCase(p.trim())) {
System.out.println("Use agent proxy printer");
printers.add(new AgentProxyPrinter());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public synchronized static ServerBootstrap getInstance(Instrumentation inst, Con
}
ServerContext.setConfiguration(config);

// if (ServerContext.isFromAgent()) {
if (ServerContext.isFromAgent()) {
// 如果从agent启动,则取消默认的标注输出和文件输出
// System.setProperty(SystemPropertyUtil.PROPERTY_JVMM_LOG_PRINTERS, "agentProxy");
// }
System.setProperty(SystemPropertyUtil.PROPERTY_JVMM_LOG_PRINTERS, "agentProxy");
}

try {
ServerContext.loadLoggerLib();
Expand Down

0 comments on commit ce67367

Please sign in to comment.