我在哪里可以找到zuul中的调试信息?

Where can i find the debug information in zuul?

我想在 ZUUL 中使用 debugFilter。当我在查询字符串中 post param "debug=true" 时,我在标准输出中找不到调试信息。

在哪里可以找到调试信息?

如果你用参数debug=true调用api,调试信息将累积到RequestContext中,关键字routingDebug。值为List<String>类型。 如果你像下面这样设置属性,调试信息将被添加到响应头中 - X-Zuul-Debug-Header.

zuul.include-debug-header=true

据我所知,此信息默认情况下不会打印到标准输出。 相反,您可以通过 com.netflix.zuul.context.Debug.getRoutingDebug() 轻松访问此信息。

您可以创建自己的 post 过滤器来轻松打印出此信息,如下所示。

@Override
public boolean shouldFilter() {
    return Debug.debugRouting();
}

@Override
public Object run() {
    String debug = convertToPrettyPrintString(Debug.getRoutingDebug());
    log.info("Filter Debug Info = \n{}", debug);
    // or System.out.println(...)
    return null;
}

private String convertToPrettyPrintString(List<String> filterDebugList) {
    return filterDebugList.stream()
        .map(s -> s.startsWith("{") ? "\t" + s : s)
        .collect(Collectors.joining("\n"));
}