View/configure Keycloak HTTP 服务器的访问日志
View/configure access log of Keycloak HTTP server
如何view/configure访问Keycloak使用的HTTP服务器的日志?
我正在尝试调查 connection_refused_error 给 Keycloak 管理员 UI。
尝试将以下 <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
):
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:write-attribute(name=prefix,value=access.)
扩展 Kohei TAMURA 的回答:
为了在不重新加载 Keycloak 的情况下配置访问日志:
添加行<access-log worker="default"
directory="${jboss.server.log.dir}" prefix="access." suffix="log"/>
standalone/configuration/standalone.xml 或
standalone/configuration/standalone-ha.xml 如果使用集群配置。
重新加载 Wildfly 服务器配置而不重新启动它:
jboss/keycloak/bin/jboss-cli.sh --connect
[standalone@localhost:9990 /] reload
如何view/configure访问Keycloak使用的HTTP服务器的日志?
我正在尝试调查 connection_refused_error 给 Keycloak 管理员 UI。
尝试将以下 <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
):
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:write-attribute(name=prefix,value=access.)
扩展 Kohei TAMURA 的回答:
为了在不重新加载 Keycloak 的情况下配置访问日志:
添加行
<access-log worker="default" directory="${jboss.server.log.dir}" prefix="access." suffix="log"/>
standalone/configuration/standalone.xml 或 standalone/configuration/standalone-ha.xml 如果使用集群配置。重新加载 Wildfly 服务器配置而不重新启动它:
jboss/keycloak/bin/jboss-cli.sh --connect [standalone@localhost:9990 /] reload