Is there any Keycloak log for users ending sessions by closing browser

We know that when we enable auditing in Keycloak, it records user events and admin events in Keycloak database, we can see them on events page, also we can see logs entries in Keycloak logs.

But,

Consider this case where, User login into app in browser, then instead of clicking logout he closes the browser window.
We observed that Keycloak does not generates any event in user events or any entry in Keycloak logs.

So far we used Keycloak log level = info and debug, root log level = info and debug.
We also observed that after closing session by closing browser window, on admin console we can still see that session under active sessions for some time. During this phase if open the app url in new window of same browser, it doesn’t show or ask login page, it directly goes inside app. But after sometime it disappears from the active session,
Can we get log for this ?

So we want know is there any way to generate log entry for such case. Or Keycloak generates any log for such case ? We are using Keycloak 18.0.2 , is there any provision in next versions ?

It’s not a Keycloak per se. You could attempt to place JavaScript on the Client application, to send logout to Keycloak on Browser close.

@meloncholia can you share some reference ?

It bears no relationship with Keycloak per se. You can Google for examples.

Okay. Thank you so much.

So almost sure what is happening here is that your sessions are expiring. You might be able to see logs if you turn debug logs on. If this is the case then you need to adjust the SSO Session Idle/Max settings, if you don’t want users to be logged out that is.

@davidfrickert
Actually what is happening here -

I recorded 2 observations related to this,

  1. When session idle = 5 mins, session max = 15 mins, Access token = 5 mins

I logged in and closed the browser in about a minute.
That session was still visible under active session on admin console.
After around 10 mins that session disappears from active sessions.
But there was still no exact log entry in keycloak logs.

  1. Now keycloak default timeout settings,
    When session idle = 30 mins, session max = 10 Hours, Access token = 5 mins

I logged in and closed the browser in about a minute.
That session was still visible under active session on admin console.
But here it took more time around 1-1.5 hours to disappear this session from active sessions.

So we can assume that the amount of time keycloak will persist such session, where user closes the browser window depends on above 3 values.