尽管您在评论中说您删除了日志子系统,但有几种方法可以通过 HTTP 管理界面下载日志文件。它们确实需要存在日志记录子系统,并且日志文件必须位于jboss.server.log.dir
已知的文件处理程序中。
卷曲:
curl --digest -L -D - http://127.0.0.1:9990/management?useStreamAsResponse --header "Content-Type: application/json" -u admin:admin.1234 -d '{"operation":"read-attribute","address":[{"subsystem":"logging"},{"log-file":"server.log"}],"name":"stream"}' -o server.log
或者在浏览器中:
http://localhost:9990/management/subsystem/logging/log-file/server.log?operation=attribute&name=stream&useStreamAsResponse
正如另一条评论所提到的,您还可以使用管理控制台本身。
另一种选择是使用管理 API 创建您自己的下载函数。
try (ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getLocalHost(), 9990)) {
final ModelNode address = Operations.createAddress("subsystem", "logging", "log-file", "server.log");
final ModelNode op = Operations.createReadResourceOperation(address);
op.get("include-runtime").set(true);
final OperationResponse response = client.executeOperation(OperationBuilder.create(op).build(), OperationMessageHandler.logging);
final ModelNode outcome = response.getResponseNode();
if (Operations.isSuccessfulOutcome(outcome)) {
final String uuid = Operations.readResult(outcome).get("stream").asString();
final InputStream in = response.getInputStream(uuid).getStream();
final byte[] buffer = new byte[64];
int len;
while ((len = in.read(buffer)) != -1) {
System.out.write(buffer, 0, len);
}
}
}
同样,尽管所有这些选项都需要使用日志记录子系统。