Event Listener for login and logout | Community
Skip to main content
ryuushihou1990
Level 2
September 10, 2024
Solved

Event Listener for login and logout

  • September 10, 2024
  • 1 reply
  • 672 views

I want to monitor when a user logs into aem and print some information into the logininfo.log file. I added an OGSI component and bound it to logininfo.log. But when I log into aem, nothing is printed into the log file. Is my EVENT_TOPIC written incorrectly?

Best answer by kapil_rajoria

Hi @ryuushihou1990 correct EVENT_TOPIC for user login in AEM is:
org/apache/sling/auth/core/AuthenticationEvent

The rest code seems correct. If changing the EVENT_TOPIC doesn't work, you can use debugger and see if your code is executing properly or not. Please share the information here.

1 reply

kapil_rajoria
Community Advisor
kapil_rajoriaCommunity AdvisorAccepted solution
Community Advisor
September 11, 2024

Hi @ryuushihou1990 correct EVENT_TOPIC for user login in AEM is:
org/apache/sling/auth/core/AuthenticationEvent

The rest code seems correct. If changing the EVENT_TOPIC doesn't work, you can use debugger and see if your code is executing properly or not. Please share the information here.

March 7, 2025

Hello @kapil_rajoria - I've tried the same above but I cannot seem to capture the event in logs.

 

@Component(service = EventHandler.class, immediate = true, property = { EventConstants.EVENT_TOPIC + "=org/apache/sling/auth/core/AuthenticationEvent" }) public class LoginEventHandler implements EventHandler { private static final Logger log = LoggerFactory.getLogger(LoginEventHandler.class); @Override public void handleEvent(Event event) { log.info("LOGIN EVENT CAPTURED: {}", event.getTopic()); } }

 What did I miss?