Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Event Listener for login and logout

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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.

Avatar

Level 1

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?