如何查看/配置Keycloak使用的HTTP服务器访问日志?
我正在尝试调查到Keycloak管理界面的 connection_refused_error 错误。
如何查看/配置Keycloak使用的HTTP服务器访问日志?
我正在尝试调查到Keycloak管理界面的 connection_refused_error 错误。
<access-log/>
标签添加到您的服务器配置文件中,例如:standalone/configuration/standalone.xml
。 <subsystem xmlns="urn:jboss:domain:undertow:4.0">
<buffer-cache name="default"/>
<server name="default-server">
...
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<!-- Add the following one line -->
<access-log prefix="access." />
<http-invoker security-realm="ApplicationRealm"/>
<filter-ref name="proxy-peer"/>
</host>
</server>
在重启Keycloak服务器后,您可以在standalone/log/
目录下看到access.log
文件,并且日志文件每天轮换一次,以access.2019-07-26.log
这样的名称保存。
编辑:
您也可以使用JBoss CLI,如下所示:
$ ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:add
{"outcome" => "success"}
这些命令将一行内容添加到standalone.xml
文件中:
<access-log/>
下一个命令显示访问日志设置(默认值):
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:read-resource
{
"outcome" => "success",
"result" => {
"directory" => expression "${jboss.server.log.dir}",
"extended" => false,
"pattern" => "common",
"predicate" => undefined,
"prefix" => "access_log.",
"relative-to" => undefined,
"rotate" => true,
"suffix" => "log",
"use-server-log" => false,
"worker" => "default"
},
"response-headers" => {"process-state" => "reload-required"}
}
你可以通过以下命令更改属性(例如prefix
):
你可以使用以下指令更改属性(例如prefix
):
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:write-attribute(name=prefix,value=access.)
扩展Kohei TAMURA的答案:
为了在不重新加载Keycloak的情况下配置访问日志:
Add line <access-log worker="default"
directory="${jboss.server.log.dir}" prefix="access." suffix="log"/>
to standalone/configuration/standalone.xml or
standalone/configuration/standalone-ha.xml if clustered configuration is used.
Reload Wildfly server configuration without restarting it:
jboss/keycloak/bin/jboss-cli.sh --connect
[standalone@localhost:9990 /] reload