jboss的Keycloak调试级别日志很混乱

gj3fmq9x  于 2022-11-08  发布在  其他
关注(0)|答案(1)|浏览(342)

我使用的是jboss/keycloak:15.0.2。为了符合安全要求,我需要启用DEBUG级别的日志来记录用户登录的成功消息。

loginservice:
    image: my-image
    environment:
    - KEYCLOAK_IMPORT=/tmp/realm-export-deploy.json
    - KEYCLOAK_USER=admin
    - KEYCLOAK_LOGLEVEL=DEBUG
    - KEYCLOAK_PASSWORD_FILE=/run/secrets/loginadmin
    - SYS_PROPS=-Dkeycloak.migration.strategy=IGNORE_EXISTING
    - PROXY_ADDRESS_FORWARDING=true
    - KEYCLOAK_FRONTEND_URL=https://servername.net/keycloak/auth
    ports:
    - 7070:8080

但是,一旦服务启动,日志就会因为重复的消息而变得混乱

08:00:30,986 DEBUG [org.keycloak.services.scheduled.ScheduledTaskRunner] (Timer-2) Executed scheduled task AbstractLastSessionRefreshStoreFactory$$Lambda$2097/0x0000000841707840
08:00:35,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) new JtaTransactionWrapper
08:00:35,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) was existing? false
08:00:35,985 DEBUG [org.keycloak.models.sessions.infinispan.changes.sessions.PersisterLastSessionRefreshStore] (Timer-2) Updating 0 userSessions with lastSessionRefresh: 1639123175
08:00:35,986 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) JtaTransactionWrapper  commit
08:00:35,986 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) JtaTransactionWrapper end
08:00:35,986 DEBUG [org.keycloak.services.scheduled.ScheduledTaskRunner] (Timer-2) Executed scheduled task AbstractLastSessionRefreshStoreFactory$$Lambda$2097/0x0000000841707840
08:00:40,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) new JtaTransactionWrapper
08:00:40,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) was existing? false
08:00:40,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) JtaTransactionWrapper  commit
08:00:40,986 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) JtaTransactionWrapper end
08:00:40,986 DEBUG [org.keycloak.services.scheduled.ScheduledTaskRunner] (Timer-2) Executed scheduled task AbstractLastSessionRefreshStoreFactory$$Lambda$2097/0x0000000841707840
08:00:45,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) new JtaTransactionWrapper
08:00:45,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) was existing? false
08:00:45,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) JtaTransactionWrapper  commit
08:00:45,985 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (Timer-2) JtaTransactionWrapper end

我从keycloak UI启用的事件:

有什么线索吗?混乱是怎么回事?如何禁用它?

vxf3dgd4

vxf3dgd41#

您不需要为所有Keycloak包启用DEBUG日志。只需为org.keycloak.events启用它就足够了。这可以通过将以下JBOSS启动脚本添加到Keycloak容器中来完成:

embed-server --server-config=standalone-ha.xml
/subsystem=logging/logger=org.keycloak.events/:add(category=org.keycloak.events,level=DEBUG)
stop-embedded-server

这将捕获日志中的大多数相关事件。

相关问题